这个程序的display函数怎么写?
// aaaa.cpp: implementation of the aaaa class.
//
//////////////////////////////////////////////////////////////////////
#include<iostream>
#include<fstream>
#include<string>
#include<iomanip>
using namespace std;
class people
{
public:
people();
virtual ~people();
virtual int lookfor(int);
protected:
char name[20];
};
class teacher:public people
{
public:
teacher();
~teacher();
void setup();
void edit();
void Delete();
int lookfor(int m);
};
class student : public people
{
public:
student();
~student();
int lookfor(int m);
friend class teacher;
protected:
int computer,math,english,yuwen;
float ave;
int num;
friend int main();
};
int main();
student stu[100];
people::people()
{
}
people::~people()
{
}
int people::lookfor(int)
{
return 0;
}
student::student()
{
}
student::~student()
{
}
int student::lookfor(int m)
{
for(int i=0;i<100;i++)
{
if(m==stu[i].num)
return i;
}
return -1;
}
teacher::teacher()
{
}
teacher::~teacher()
{
}
void teacher::setup()
{
float ave;
char str;
for(int i=0;i<100;i++)
{
cout<<"请输入学生学号:";
cin>>stu[i].num;
cout<<"姓名:";
cin>>stu[i].name;
cout<<"计算机成绩:";
cin>>stu[i].computer;
cout<<"高数成绩:";
cin>>stu[i].math;
cout<<"英语成绩:";
cin>>stu[i].english;
cout<<"语文成绩:";
cin>>stu[i].yuwen;
stu[i].ave=(stu[i].computer+stu[i].math+stu[i].english+stu[i].yuwen)/4;
cout<<"继续(y/n)\n";
cin>>str;
if(str=='n')
break;
else if(str=='y') continue;
else if(str!='n'&&str!='y')
{
cout<<"错误操作\n";
break;
}
else ;
}
}
int teacher::lookfor(int m)
{
for(int i=0;i<100;i++)
{
if(m==stu[i].num)
return i;
}
return -1;
}
void teacher::edit()
{
char ch[30];
int s1,s2,s3,s4;
int t,m,temp;
cout<<"请选择学号:";
cin>>m;
temp=lookfor(m);
if(m!=-1)
{
system("cls");
cout<<"******欢迎进入学生信息管理系统*****\n";
cout<<" 请选择您的操作: \n";
cout<<" 1 - 修改姓名 \n";
cout<<" 2 - 修改计算机成绩 \n";
cout<<" 3 - 修改高数成绩 \n";
cout<<" 4 - 修改英语成绩 \n";
cout<<" 5 - 修改语文成绩 \n";
cout<<"******************************\n";
cout<<"请输入:";
cin>>t;
switch (t)
{
case 1:
cout<<"请输入新的学生名字\n";
cin>>ch;
strcpy(stu[temp].name,ch);
break;
case 2:
cout<<"请输入学生新的计算机成绩\n";
cin>>s1;
stu[temp].computer=s1;
break;
case 3:
cout<<"请输入学生新的高数成绩\n";
cin>>s2;
stu[temp].math=s2;
break;
case 4:
cout<<"请输入学生新的英语成绩\n";
cin>>s3;
stu[temp].english=s3;
break;
case 5:
cout<<"请输入学生新的语文成绩\n";
cin>>s4;
stu[temp].yuwen=s4;
break;
}
}
else
cout<<"此学号不存在!\n";
}
void teacher::Delete()
{
int m;
cout<<"请选择学号:";
cin>>m;
int temp=0;
temp=stu[temp].lookfor(m);
if(m==stu[temp].num)
{
stu[temp].num=0;
stu[temp].name[20]='0';
stu[temp].computer=0;
stu[temp].math=0;
stu[temp].english=0;
stu[temp].yuwen=0;
}
else
cout<<"此学号不存在!\n";
}
int main()
{
int t;
cout<<"*************欢迎进入学生信息管理系统**********\n"<<endl;
cout<<" 1.管理员:"<<endl;
cout<<" 2.学生:"<<endl;
cout<<"***********************************************\n"<<endl;
cout<<"请输入:";
cin>>t;
if(t==1)
{
char m[20],n[10];
system("cls");
cout<<"请输入用户名:";
cin>>m;
cout<<"请输入密码:";
cin>>n;
if(strcmp(m,"111")==0 && strcmp(n,"123")==0)
{
loop:
system("cls");
cout<<"*************欢迎进入学生信息管理系统**********\n";
cout<<" 请选择您的操作 \n";
cout<<" 1 - 录入学生信息 \n";
cout<<" 2 - 查找学生信息 \n";
cout<<" 3 - 修改学生信息 \n";
cout<<" 4 - 删除学生信息 \n";
cout<<" 5 - 退出 \n";
cout<<"***********************************************\n";
cout<<"请输入:";
int menu,num,tem;
cin>>menu;
system("cls");
switch (menu)
{
case 1:
{
teacher *m = new teacher();
m->setup();
system("cls");
goto loop;
break;
}
case 2:
{
cout<<"请输入您想查询的学号:";
cin>>num;
tem=stu[0].lookfor(num);
if (tem!=-1)
{
cout<<"学号 姓名 计算机 高数 英语 语文 平均成绩\n";
cout<<stu[tem].num<<" "<<stu[tem].name<<" "<<stu[tem].computer<<" "<<stu[tem].math<<" "<<stu[tem].english<<" "<<stu[tem].yuwen<<" "<<stu[tem].ave<<endl;
}
else
cout<<"对不起,该学号不存在!\n";
system("pause");
system("cls");
goto loop;
break;
}
case 3:
{
teacher *m = new teacher();
m->edit();
system("cls");
goto loop;
break;
}
case 4:
{
teacher *m = new teacher();
m->Delete();
system("cls");
goto loop;
break;
}
case 5:
{
cout<<"谢谢使用!\n";
break;
}
default:
{
cout<<"错误的请求!\n";
system("cls");
goto loop;
break;
}
}
return 0;
}
else
{
cout<<"请重新输入!"<<endl;
}
}
else if(t=2)
{
se:
system("cls");
cout<<"*********欢迎进入学生信息管理系统**********"<<endl;
cout<<" 请选择服务 "<<endl;
cout<<" 1.录入学生信息 "<<endl;
cout<<" 2.查询学生信息 "<<endl;
cout<<" 0.退出系统 "<<endl;
cout<<"*******************************************"<<endl;
int menu,num,tem;
cin>>menu;
system("cls");
switch (menu)
{
case 1:
{
teacher *t = new teacher();
t->setup();
system("cls");
goto se;
break;
}
case 2:
{
cout<<"请输入您想查询的学号:";
cin>>num;
tem=stu[0].lookfor(num);
if (tem!=-1)
{
cout<<"学号 姓名 计算机 高数 英语 语文 平均成绩\n";
cout<<stu[tem].num<<" "<<stu[tem].name<<" "<<stu[tem].computer<<" "<<stu[tem].math<<" "<<stu[tem].english<<" "<<stu[tem].yuwen<<" "<<stu[tem].ave<<endl;
}
else
cout<<"对不起,该学号不存在!\n";
system("pause");
system("cls");
goto se;
break;
}
case 0:
{
cout<<"谢谢使用!\n";
break;
}
default:
{
cout<<"错误的请求!\n";
system("cls");
goto loop;
break;
}
}
}
}