词文 2019-12-29 23:09 采纳率: 0%
浏览 245

这个运行结果是怎样的,咋感觉我不会显示它的输出呢?

#include"iostream"
#include
#include"stdlib.h"
#define MAX 100
using namespace std;
class person
{
public:
int num;
char name[20];
char sex[4];
int age;
};
//Teacher class
class Teacher:virtual public person
{
public:
char dept[20];
char special[20];
char title[20];
void Input()
{
cout<<"Input num:";cin>>num;
cout<<"Input name:";cin>>name;
cout<<"Input sex:";cin>>sex;
cout<<"Input age:";cin>>age;
cout<<"Input dept:";cin>>dept;
cout<<"Input special:";cin>>special;
cout<<"Input title:";cin>>title;
}
void Output()
{
cout<<"编号: "<<num<<" "<<"姓名: "<<name<<" "<<"性别: "<<sex<<" "<<"年龄: "<<age<<
" "<<"所在系: "<<dept<<" "<<"专业: "<<special<<" "<<"职称: "<<title<<endl;
}
};
Teacher Tea[MAX];
static int Teatop;

class TeaManager
{
public:
int Add();
int Search();
void Show();
void Edit();
int Delete();
void Save();
void Read();
};
int TeaManager::Add()
{
Teacher t;
int i,nu;
if(Teatop==MAX)
{cout<<"人数已满"< return 0;
}
cout>nu;
for(i=0;i {
if(nu==Tea[i].num)
{cout return 0;
}
}
t.Input();Tea[Teatop]=t;Teatop++;
cout return 1;
}
int TeaManager::Search()
{
int j,n;
cout>n;
for(j=0;j {
if(n==Tea[j].num) break;
}
if(j==Teatop)
cout else
Tea[j].Output();
return 1;
}
void TeaManager::Show()
{
int i;
if(Teatop==0)
{cout for(i=0;i Tea[i].Output();
}
void TeaManager::Edit()
{
Teacher t1;
int j,n;
cout>n;
for(j=0;j {
if(n==Tea[j].num) break;
}
if(j==Teatop)
{cout cout t1.Input();
Tea[j]=t1;
cout }
int TeaManager::Delete()
{
int j,n;
cout>n;
for(j=0;j {
if(n==Tea[j].num) break;
}
if(j==Teatop)
{cout for(j;j {
Tea[j]=Tea[j+1];
}
Teatop--;
cout return 1;
}
void TeaManager::Save()
{
int i;
ofstream outfile,outfile1;
outfile1.open("Teatop.dat",ios::out);
outfile1 outfile.open("Tea_data.dat",ios::binary);
if(!outfile)
{cerr for(i=0;i outfile.write((char *)&Tea[i],sizeof(Tea[i]));
outfile.close();
cout }
void TeaManager::Read()
{
int i;
ifstream infile,infile1;
infile1.open("Teatop.dat",ios::in);
infile1>>Teatop;
infile.open("Tea_data.dat",ios::binary);

if(!infile)
{cerr<<"open error!"< for(i=0;i infile.read((char *)&Tea[i],sizeof(Tea[i]));
infile.close();
cout }
void Tea_mune(TeaManager TM)
{
int b;
char c;
do{
cout cout cout cout cout cout cout cout cout cout cout cout cout>b;
switch(b)
{
case 1:TM.Add();break;
case 2:TM.Search();break;
case 3:TM.Show();break;
case 4:TM.Edit();break;
case 5:TM.Delete();break;
case 6:cout<<"共有教师人数:"<<Teatop<<endl;break;
case 7:TM.Save();break;
case 8:TM.Read();break;
default:cout<<"\n error"<<endl;break;
case 0:break;
}
cout<<"按回车键继续"<<endl;
flushall();
c=getchar();
system("cls");
}while(b!=0);
}

class Tester:virtual public person
{
public:
char testroom[10];
char post[10];
void Input()
{
cout<<"Input num:";cin>>num;
cout<<"Input name:";cin>>name;
cout<<"Input sex:";cin>>sex;
cout<<"Input age:";cin>>age;
cout<<"Input testroom:";cin>>testroom;
cout<<"Input post:";cin>>post;
}
void Output()
{
cout<<"编号: "<<num<<" "<<"姓名: "<<name<<" "<<"性别: "<<sex<<" "<<"年龄: "<<age<<
" "<<"所在实验室: "<<testroom<<" "<<"职务: "<<post<<endl;
}

};
Tester Test[MAX];
static int Testop;
class TestManager
{
public:
int Add();
int Search();
void Show();
void Edit();
int Delete();
void Save();
void Read();
};
int TestManager::Add()
{
Tester t;
int i,nu;
if(Testop==MAX)
{cout<<"人数已满"< return 0;
}
cout>nu;
for(i=0;i {
if(nu==Test[i].num)
{cout return 0;
}
}
t.Input();
Test[Testop]=t;
Testop++;
cout return 1;
}
int TestManager::Search()
{
int j,n;
cout>n;
for(j=0;j {
if(n==Test[j].num) break;
}
if(j==Testop)
cout else
Test[j].Output();
return 1;
}
void TestManager::Show()
{
int i;
if(Testop==0)
{cout for(i=0;i Test[i].Output();
}
void TestManager::Edit()
{
Tester t1;
int j,n;
cout>n;
for(j=0;j {
if(n==Test[j].num) break;
}
if(j==Testop)
{cout cout t1.Input();
Test[j]=t1;
cout }
int TestManager::Delete()
{
int j,n;
cout>n;
for(j=0;j {
if(n==Test[j].num) break;
}
if(j==Testop)
{cout for(j;j {
Test[j]=Test[j+1];
}
Testop--;
cout return 1;
}
void TestManager::Save()
{
int i;
ofstream outfile,outfile1;
outfile1.open("Testop.dat",ios::out);
outfile1 outfile.open("Test_data.dat",ios::binary);
if(!outfile)
{cerr for(i=0;i outfile.write((char *)&Test[i],sizeof(Test[i]));
outfile.close();
cout }
void TestManager::Read()
{
int i;
ifstream infile,infile1;
infile1.open("Testop.dat",ios::in);
infile1>>Testop;
infile.open("Test_data.dat",ios::binary);

if(!infile)
{cerr<<"open error!"< for(i=0;i infile.read((char *)&Test[i],sizeof(Test[i]));
infile.close();
cout }
void Test_mune(TestManager TM)
{
int b;
char c;
do{
cout cout cout cout cout cout cout cout cout cout cout cout cout>b;
switch(b)
{
case 1:TM.Add();break;
case 2:TM.Search();break;
case 3:TM.Show();break;
case 4:TM.Edit();break;
case 5:TM.Delete();break;
case 6:cout<<"共有实验员人数:"<<Testop<<endl;break;
case 7:TM.Save();break;
case 8:TM.Read();break;
default:cout<<"\n error"<<endl;break;
case 0:break;
}
cout<<"按回车键继续"<<endl;
flushall();
c=getchar();
system("cls");
}while(b!=0);
}

class Policer:virtual public person
{
public:
char polices[10];
char post1[10];
void Input()
{
cout<<"Input num:";cin>>num;
cout<<"Input name:";cin>>name;
cout<<"Input sex:";cin>>sex;
cout<<"Input age:";cin>>age;
cout<<"Input polices:";cin>>polices;
cout<<"Input post1:";cin>>post1;
}
void Output()
{
cout<<"编号: "<<num<<" "<<"姓名: "<<name<<" "<<"性别: "<<sex<<" "<<"年龄: "<<age<<
" "<<"政治面貌: "<<polices<<" "<<"职称: "<<post1<<endl;
}

};
Policer Policers[MAX];
static int Policersop;
class PolicerManager
{
public:
int Add();
int Search();
void Show();
void Edit();
int Delete();
void Save();
void Read();
};
int PolicerManager::Add()
{
Policer t;
int i,nu;
if(Policersop==MAX)
{cout<<"人数已满"< return 0;
}
cout>nu;
for(i=0;i {
if(nu==Policers[i].num)
{cout return 0;
}
}
t.Input();
Policers[Policersop]=t;
Policersop++;
cout return 1;
}
int PolicerManager::Search()
{
int j,n;
cout>n;
for(j=0;j {
if(n==Policers[j].num) break;
}
if(j==Policersop)
cout else
Policers[j].Output();
return 1;
}
void PolicerManager::Show()
{
int i;
if(Policersop==0)
{cout for(i=0;i Policers[i].Output();
}
void PolicerManager::Edit()
{
Policer t1;
int j,n;
cout>n;
for(j=0;j {
if(n==Policers[j].num) break;
}
if(j==Policersop)
{cout cout t1.Input();
Policers[j]=t1;
cout }
int PolicerManager::Delete()
{
int j,n;
cout>n;
for(j=0;j {
if(n==Policers[j].num) break;
}
if(j==Policersop)
{cout for(j;j {
Policers[j]=Policers[j+1];
}
Policersop--;
cout return 1;
}
void PolicerManager::Save()
{
int i;
ofstream outfile,outfile1;
outfile1.open("Policersop.dat",ios::out);
outfile1 outfile.open("Policers_data.dat",ios::binary);
if(!outfile)
{cerr for(i=0;i outfile.write((char *)&Policers[i],sizeof(Policers[i]));
outfile.close();
cout }
void PolicerManager::Read()
{
int i;
ifstream infile,infile1;
infile1.open("Policersop.dat",ios::in);
infile1>>Policersop;
infile.open("Policers_data.dat",ios::binary);

if(!infile)
{cerr<<"open error!"< for(i=0;i infile.read((char *)&Policers[i],sizeof(Policers[i]));
infile.close();
cout }
void Policers_mune(PolicerManager TM)
{
int b;
char c;
do{
cout cout cout cout cout cout cout cout cout cout cout cout cout>b;
switch(b)
{
case 1:TM.Add();break;
case 2:TM.Search();break;
case 3:TM.Show();break;
case 4:TM.Edit();break;
case 5:TM.Delete();break;
case 6:cout<<"共有行政员人数:"<<Policersop<<endl;break;
case 7:TM.Save();break;
case 8:TM.Read();break;
default:cout<<"\n error"<<endl;break;
case 0:break;
}
cout<<"按回车键继续"<<endl;
flushall();
c=getchar();
system("cls");
}while(b!=0);
}

int main()
{
TeaManager Tmer1;
TestManager Tetmer;
PolicerManager Polimer;
int a=1,m=0;
char c;
cout<<" *************************************";
cout< cout cout>m;

if(m!=666) 
{
    cout<<"密码错误!"<<endl;
    flushall();
    c=getchar();
    return 0;
}
while(a)
{
    system("cls");
    cout<<endl;
    cout<<"              ****欢迎使用高校人员信息管理系统****"<<endl;
    cout<<"               ================================="<<endl;
    cout<<"               | 1.教师管理                    |"<<endl;
    cout<<"               | 2.实验员管理                  |"<<endl;
    cout<<"               | 3.行政员管理                  |"<<endl;
    cout<<"               | 0.退出                        |"<<endl;
    cout<<"               ================================="<<endl;
    cout<<"请选择:";cin>>a;  

    switch(a)
    {
    case 1:Tea_mune(Tmer1);break;
    case 2:Test_mune(Tetmer);break;
    case 3:Policers_mune(Polimer);break;
    case 0:break;
    default:cout<<"\n error"<<endl;
    cout<<"按回车键继续"<<endl;
    flushall();
    c=getchar();         
    break;
    }
}
cout<<endl<<"谢谢使用"<<endl;
flushall();
c=getchar();
return 0;

}

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
    • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
    • ¥20 软件测试决策法疑问求解答
    • ¥15 win11 23H2删除推荐的项目,支持注册表等
    • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
    • ¥15 qt6.6.3 基于百度云的语音识别 不会改
    • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
    • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
    • ¥15 lingo18勾选global solver求解使用的算法
    • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行