time limit: 1000 ms memory limit: 65536 kib
submit
statistic
discuss
problem description
已知二叉樹的乙個按先序遍歷輸入的字串行,如abc,,de,g,,f,,, (其中,表示空結點)。請建立二叉樹並求二叉樹的葉子結點個數。
input
連續輸入多組資料,每組資料輸入乙個長度小於50個字元的字串。
output
輸出二叉樹的葉子結點個數。
sample input
abc,,de,g,,f,,,
sample output
3
#include #include #include struct node
;char s[100];
int i,k;
struct node *creat()
else
return root;
}void num(struct node *root)
num(root->lt);
num(root->rt);
}}int main()
return 0;
}
SDUT OJ 資料結構實驗之二叉樹五 層序遍歷
time limit 1000ms memory limit 65536k 已知乙個按先序輸入的字串行,如abd,eg,cf,其中,表示空結點 請建立二叉樹並求二叉樹的層次遍歷序列。輸入資料有多行,第一行是乙個整數t t 1000 代表有 t行測試資料。每行是 乙個長度小於50 個字元的字串。輸出二...
SDUT OJ資料結構實驗之二叉樹三 統計葉子數
time limit 1000ms memory limit 65536k 已知二叉樹的乙個按先序遍歷輸入的字串行,如abc,de,g,f,其中,表示空結點 請建立二叉樹並求二叉樹的葉子結點個數。連續輸入多組資料,每組資料輸入乙個長度小於50個字元的字串。輸出二叉樹的葉子結點個數。abc,de,g,...
SDUT OJ 資料結構實驗之二叉樹六 哈夫曼編碼
time limit 1000 ms memory limit 65536 kib submit statistic discuss problem description 字元的編碼方式有多種,除了大家熟悉的ascii編碼,哈夫曼編碼 huffman coding 也是一種編碼方式,它是可變字長編...