求高手看下为什么输出不显示
#include<iostream>#include<stdio.h>
#include<conio.h>
using namespace std;
struct student
{
char name[10];
int num;
int cpp;
int math;
int all;
};
typedef struct BiTNode
{
student data;
int classnum;
int classlen;
int roomnum;
int roomlen;
struct BiTNode *lchild,*rchild;
}BiTNode,*BiTree;
void create(BiTree &T)
{
T=(BiTree)malloc(sizeof(BiTNode));
T->lchild=NULL;
T->rchild=NULL;
}
void input(BiTree &T)
{
BiTree p;
p=new(BiTNode);
// BiTNode *P;//班级
BiTNode *q;//宿舍
BiTNode *t1;//学生
int m;
int n;
while(1)
{
BiTree p;
p=new(BiTNode);
cout<<"输入班级号(如1班,当输入班级号为0时退出)";
cin>>m;
p=(BiTree)malloc(sizeof(BiTNode));
p->lchild=NULL;
p->rchild=NULL;
p->classlen=0;
if(m==0)
break;
else
{
p->classnum=m;
p->lchild=q;
}
while(1)
{
BiTree q;
q=new(BiTNode);
cout<<"请输入宿舍号(宿舍号为0时退出)";
cin>>n;
q=(BiTree)malloc(sizeof(BiTNode));
q->lchild=NULL;
q->rchild=NULL;
q->roomlen=0;
if(n==0)
break;
else
{
q->lchild=t1;
q->roomlen=n;
}
for(int i=0;i<6;i++)
{
t1=(BiTree)malloc(sizeof(BiTNode));
t1->lchild=NULL;
t1->rchild=NULL;
cout<<"请输入学生的学号(学号为0时退出)";
cin>>t1->data.num;
if(t1->data.num==0)
break;
else
{
cout<<"输入学生姓名";
cin>>t1->data.name;
cout<<"输入C++成绩";
cin>>t1->data.cpp;
cout<<"输入数学成绩";
cin>>t1->data.math;
}
t1=t1->rchild;//学生
}
(q->roomlen)++;
q=q->rchild;
}
(p->classlen)++;
p->rchild=p;
}
}
void output(BiTree &T)
{
BiTree p;
p=new(BiTNode);
BiTNode *P;//班级
BiTNode *q;//宿舍
BiTNode *t1;//学生
int a;
cout<<"请输入要查询的班级号码";
cin>>a;
while(a==0)
{
cout<<"输入有误,请重新输入!";
break;
}
p=T;
while(p->rchild)
{
// p=T;
if(p->classnum==a)
{
p->lchild=q;
while(q)
{
q->lchild=t1;
while(t1)
{
cout<<"学号"<<t1->data.num;
cout<<"姓名"<<t1->data.name;
cout<<"C++成绩"<<t1->data.cpp;
cout<<"数学成绩"<<t1->data.math;
t1=t1->rchild;
}
q=q->rchild;
}
}
else
p=p->rchild;
}
}
void main()
{
BiTNode *T;
char c;
create(T);
cout<<"\n\n\n\n\n\n\n\n\t\t\t "<<"欢迎使用学生成绩管理系统\n\n\n";
cout<<"\t\t\t\t 2011版";
getch();
while(c)
{
system("cls");
cout<<"\n\n\n\n\t\t\t 学生个人信息管理菜单\n\n\n\n\n\n";
cout<<"\t\t\t 1:输入\n\n\n";
cout<<"\t\t\t 2:输出\n\n\n";
cout<<"\t\t\t 0:退出\n\n\n";
cout<<"你的输入为;";
c=getch();
switch (c)
{
case '1':
system("cls");
input(T);
break;
case '2':
system("cls");
output(T);
getch();
break;
case '0':
system("cls");
getch();
exit(0);
break;
default:
cout<<"选项有误,请重新选择!\n";
break;
}
}
}