运行程序的时候可以输入但是输不出来东西,请问是哪里出错了?
#include<iostream>
#include <stdlib.h>
#include <stdio.h>
#include <malloc.h>
using namespace std;
char ch;
typedef struct bitnode{
char data;
struct bitnode *lchild,*rchild;
}bitnode,*bitree;
int createbitree(bitree &T)
{
scanf("%c",&ch);
if(ch==' ') T=NULL;
else{
if(!(T= (bitnode*)malloc(sizeof(bitnode))))
exit(0);
T->data=ch;
createbitree(T->lchild);
createbitree(T->rchild);
}
return 1;
}
int inorder(bitnode *T)
{
if(T!=NULL){
inorder(T->lchild);
cout<<T->data;
inorder(T->rchild);}
return 0;
}
int main()
{
bitnode *F;
bitnode *Q;
cout<<"请输入二叉树";
createbitree(F);
inorder(Q);
return 0;
}
用f5单步运行调试下。你这是要做什么?顺序遍历?