資源簡介
1.廣義表創建二叉樹 比如:A(B(,G),C(D(F),E))
2.二叉樹輸出廣義表
代碼片段和文件信息
#include?
#include??
#include??
#include?
#define?STR_MAX?100
template??struct?BTNode?{
DataType?value;
struct?BTNode?*lchild;
struct?BTNode?*rchild;
explicit?BTNode(DataType?x)?:?value(x)?lchild(NULL)?rchild(NULL)?{}
};
//?seperate?the?text?into?two?segements?by?a?char
//?sample:?AB?--(‘‘)-->?A?B
int?seperateStr(const?char?*str?char?*recv_1?char?*recv_2?const?char?sign)?{
if?(!str)?return?-1;
for?(int?i?=?0;?str[i]?!=?sign;?i++)?{
if?(recv_1)
recv_1[i]?=?str[i];
}
if?(recv_1)
recv_1[i]?=?‘\0‘;
i++;
for?(int?j?=?0?;?str[i]?!=?‘\0‘;?i++?j++)?{
if?(recv_2)
recv_2[j]?=?str[i];
}
if?(recv_2)
recv_2[j]?=?‘\0‘;
return?0;
}
?
//?Translate?the?string?to?a?BTree
//?sa
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????2619??2018-12-24?02:53??BTree.cpp
評論
共有 條評論