文章
13
粉丝
0
获赞
94
访问
1.2k
这破提示误导我,我以为还要补全#呢
#include<bits/stdc++.h>
using namespace std;
string s;
int i = 0;
typedef struct node{
char data;
struct node *left,*right;
}node,*BitTree;
void CreateBitTree(BitTree &T){
char x = s[i++];
if(i>s.size())return;
if(x== '#')
T = NULL;
else{
T = new node;
T->data = x;
T->left = NULL;
T->right = NULL;
CreateBitTree(T->left);
CreateBitTree(T->right);
}
}
void InOrder(BitTree T){
if(T != NULL){
InOrder(T->left);
cout << T->data << " ";
InOrder(T->right);
}
}
int main(){
while(cin >> s){
BitTree T;
CreateBitTree(T);
InOrder(T);
cout << endl;
i=0;
}
return 0;
}
登录后发布评论
暂无评论,来抢沙发