为什么不能输出多组测试用例啊?搞不懂!求助
#include<stdio.h> #include<stdlib.h>
#define OK 1
#define ERROR 0
#define NULL 0
typedef int Status;
typedef char ElemType;
typedef struct CSNode
{
ElemType data;
struct CSNode *lchild,*rchild;
}CSNode,*CSTree;
Status CreateCSTree(CSTree &T)
{
char d;
scanf("%c",&d);
if(d=='#')
T=NULL;
else
{
T=(CSNode*)malloc(sizeof(CSNode));
T->data=d;//生成根节点
CreateCSTree(T->lchild);//构造第一个孩子结点
CreateCSTree(T->rchild);//构造兄弟结点
}
return OK;
}
int LeafCount_CSTree(CSTree T,int &count)
{
if(T)
{
if(T->lchild==NULL&&T->rchild==NULL)
count++;
LeafCount_CSTree(T->lchild,count);
LeafCount_CSTree(T->rchild,count);
}
return count;
}
int main()
{
int t,i;
scanf("%d\n",&t);
for(i=0;i<t;i++)
{
CSTree T;
int count=0;
CreateCSTree(T);
LeafCount_CSTree(T,count);
printf("%d\n",count);
}
return 0;
}