加油!!!
#include<stdio.h>
#include<stdlib.h>
#include<queue>
using namespace std;
typedef struct No{
char date;
No* left;
No* right;
} Node;
///完全二叉树的建立///
Node *creatbt()
{
Node *root=NULL,*s;
queue<Node*>Q;
char a;
int count=0;
while(scanf("%c",&a),a!='#'){
s=NULL;
if(a!='@'){
s=(Node*)malloc(sizeof(Node));
s->date=a;
s->left=NULL;
s->right=NULL;
}
Q.push(s);
count++;
if(count==1)
root=s;
else{
if(s&&!Q.empty())
if(count%2==0)
Q.front()->left=s;
else Q.front()->right=s;
if(count%2==1)Q.pop();
}
}
return root;
}
void printt(Node *t)
{
if(t){
printt(t->left);
printf("%c",t->date);
printt(t->right);
}
}
main()
{
Node* root;
printf("请按照前序输入字符:/n");
root=creatbt();
printf("按照中序遍历的结果是:/n");
printt(root);
return 0;
}