史萊姆論壇

史萊姆論壇 (http://forum.slime.com.tw/)
-   程式語言討論區 (http://forum.slime.com.tw/f76.html)
-   -   Expression tree以 遞迴式 求出樹的 depth (http://forum.slime.com.tw/thread193810.html)

baronterry 2006-12-17 08:45 PM

Expression tree以 遞迴式 求出樹的 depth
 
如題 這次我又被擊倒了= =||
Input

第一行為數字 n,代表運算式 token數 (token 是運算子或是運算元或是左括號或是右括號)。例如 A + B 表示有3個 tokens : A、+、和B。
接者n行為運算式,一行一個 token。
 
Output

整數。
Sample Input 0

1
A
 

Sample Output 0

1
Sample Input 1

3
A
+
B
Sample Output 1

2
 

Sample Input 2

9
A
+
B
*
(
C
-
D
)
 

Sample Output 2

4
類似這些sample
能告訴我怎麼寫嗎
拜託各位大大了:dcft689kj


所有時間均為台北時間。現在的時間是 09:03 AM

Powered by vBulletin® 版本 3.6.8
版權所有 ©2000 - 2025, Jelsoft Enterprises Ltd.

『服務條款』

* 有問題不知道該怎麼解決嗎?請聯絡本站的系統管理員 *


SEO by vBSEO 3.6.1