| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 358 人关注过本帖
标题:求高手看下为什么输出不显示
取消只看楼主 加入收藏
yp8023
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2011-4-29
收藏
 问题点数:0 回复次数:0 
求高手看下为什么输出不显示
#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;
        }
    }
}
搜索更多相关主题的帖子: include create 
2011-06-16 15:33
快速回复:求高手看下为什么输出不显示
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.075958 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved