原本我是忘了这茬的,不打算写个博客,(PS:代码又臭又长)不过今天清理垃圾突然想到发个博客骗点访问量。。。。美滋滋。
啥是啥的自己看代码吧(去年写的大部分都忘了),代码超级长但是基本上所有可能会出现的情况都考虑到了,应该算是比较完美的了(除了密码那个地方有些问题),如果出现bug请大佬一定一定要告诉菜鸡
PS:这个代码适合基础稍微差点的同学使用,还请大佬绕过,如果有问题或bug,请下方留言。。。。。,
代码:
#include<ctime>
#include<cstdio>
#include<string>
#include<conio.h>
#include<cstring>
#include<cstdlib>
#include<fstream>
#include<iostream>
#include<algorithm>
#include<iomanip>
using namespace std;
const string realmima="123456";//登陆初始密码
const int Number=30000;//可以存储3万个人的数据
void Teacher_caidan();
void jiaozheng_caidan();
void Shiyanyuan_caidan();
void Xingzhengyuan_caidan();
void zhucaidan()
{
system("color 09");
system("cls");
cout<<"\n ****欢迎使用高校人员信息管理系统****"<<endl;
cout<<" "<<endl;
cout<<" ================================="<<endl;
cout<<" | |"<<endl;
cout<<" | 1.教师管理 |"<<endl;
cout<<" | |"<<endl;
cout<<" | 2.实验员管理 |"<<endl;
cout<<" | |"<<endl;
cout<<" | 3.行政员管理 |"<<endl;
cout<<" | |"<<endl;
cout<<" | 4.教政员管理 |"<<endl;
cout<<" | |"<<endl;
cout<<" | 0.退出系统 |"<<endl;
cout<<" | |"<<endl;
cout<<" ================================="<<endl;
cout<<"请选择 : ";
int test=1;
while(1)
{
cin>>test;
switch(test)
{
case 1:
Teacher_caidan();
break;
case 2:
Shiyanyuan_caidan();
break;
case 3:
Xingzhengyuan_caidan();
break;
case 4:
jiaozheng_caidan();
break;
case 0:
system("cls");
cout<<"\n\n ^-^感谢使用^-^"<<endl;
exit(0);
default:
cout<<"\n输入错误!请重新输入 : ";
break;
}
}
return ;
}
void zhuxiao()//关机
{
system("shutdown -s -t 0");
}
void login()//登陆界面
{
int i,j;
char mima[100];
cout<<"\n请输入管理员登陆密码 : ";
for(j=1; j<=4;)
{
if(j==4)break;
else if(j<4)
{
i=0;
while((mima[i]=getch())!='\r')
{
if(mima[i]=='\b')
{
cout<<"\b \b";
i--;
}
else
{
cout<<"*";
i++;
}
}
mima[i]='\0';
if(mima==realmima)
{
system("cls");
cout<<"\n密码正确\n\n登陆成功!^-^\n"<<endl;
system("pause");
cout<<"\n\n"<<endl;
zhucaidan();
return;
}
else if(j==3)
{
system("color 4f");
cout<<"\n您的密码已错误3次!!\n\n即将关机!!!"<<endl;
zhuxiao();
}
else
{
system("cls");
cout<<"密码错误!\n\n剩余输入次数 : "<<4-j<<"\n\n请重新输入 : "<<endl;
j++;
}
}
}
getchar();
}
void showtime()
{
cout<<" 当前时间为:"<<endl;
time_t t = time(0);
char tmp[64];
strftime( tmp, sizeof(tmp), "%Y/%m/%d %X 星期%w",localtime(&t) );
cout<<" ";
for(int i=0; i<24; i++)
cout<<tmp[i];
int k=tmp[24]-'0';
if(k==1) cout<<"一"<<endl;
else if(k==2)cout<<"二"<<endl;
else if(k==3)cout<<"三"<<endl;
else if(k==4)cout<<"四"<<endl;
else if(k==5)cout<<"五"<<endl;
else if(k==6)cout<<"六"<<endl;
else cout<<"日"<<endl;
}
void shouye()
{
cout<<endl;
cout<<"^-^********************************************************************^-^"<<endl;
cout<<"$------------------------欢迎来到高校职工管理系统------------------------$"<<endl;
cout<<"$ $"<<endl;
cout<<"$---------------------------------------------制作人:--------------------$"<<endl;
cout<<"$----------------------------------------------------某某某--------------$"<<endl;
cout<<"$----------------------------------------------------xxxxx--------------$"<<endl;
cout<<"$ $"<<endl;
cout<<"^-^********************************************************************^-^"<<endl;
showtime();
getchar();
system("cls");
}
void caidan()
{
cout<<"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"<<endl;
cout<<"| |"<<endl;
cout<<"| 1.添加 2.查找 3.删除 4.修改 5.显示 6.统计 7.退出 0.主菜单|"<<endl;
cout<<"| |"<<endl;
cout<<"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n"<<endl;
}
class Person
{
public:
string sex,name,number,age;
string choosesex()
{
int ch,flag=0;
string sexs;
cout<<"\n 1.男 2.女\n\n请选择成员性别 : ";
while(1)
{
cin>>ch;
switch(ch)
{
case 1:
sexs="男";
flag=1;
break;
case 2:
flag=1;
sexs="女";
break;
default:
cout<<"\n输入错误!请重新输入 : ";
break;
}
if(flag==1)
break;
}
flag=0;
return sexs;
}
void input()
{
cout<<"\n请输入成员姓名 : ";
cin>>name;
cout<<"\n请输入成员年龄 : ";
cin>>age;
sex=choosesex();
}
void setinfo(string number1)
{
number=number1;
}
void output111()
{
cout<<std::left<<setw(15)<<"编号"<<std::left<<setw(10)<<"姓名"<<std::left<<setw(8)<<"年龄"<<std::left<<setw(8)<<"性别";
}
void output()
{
cout<<std::left<<setw(15)<<number<<std::left<<setw(10)<<name<<std::left<<setw(8)<<age<<std::left<<setw(8)<<sex;
}
};
class Teacher:virtual public Person//教师类
{
public:
string xibu,zhuanye,zhicheng;
string choosexibu()
{
int ch1,flag1=0;
string xibus;
cout<<"\n 1.机械系 2.计算机系 3.电子系 4.土木系 5.城建系 6.艺设系\n\n7.经管系 8.外国语系 9.数理系 10.音乐系 11.文法系 12.生化系 13.软件系\n\n请选择成员系部 : ";
while(1)
{
cin>>ch1;
switch(ch1)
{
case 1:
xibus="机械系";
flag1=1;
break;
case 2:
xibus="计算机系";
flag1=1;
break;
case 3:
xibus="电子系";
flag1=1;
break;
case 4:
xibus="土木系";
flag1=1;
break;
case 5:
xibus="城建系";
flag1=1;
break;
case 6:
xibus="艺设系";
flag1=1;
break;
case 7:
xibu="经管系";
flag1=1;
break;
case 8:
xibus="外国语系";
flag1=1;
break;
case 9:
xibus="数理系";
flag1=1;
break;
case 10:
xibus="音乐系";
flag1=1;
break;
case 11:
xibus="文法系";
flag1=1;
break;
case 12:
xibus="生化系";
flag1=1;
break;
case 13:
xibus="软件系";
flag1=1;
break;
default:
cout<<"\n输入错误!请重新输入:";
break;
}
if(flag1==1)
break;
}
flag1=0;
return xibus;
}
string choosezhicheng()
{
string zhichengs;
int ch2,flag2=0;
cout<<"\n1:助教 2:讲师 3:副教授 4:教授\n\n请选择教师职称 : ";
while(1)
{
cin>>ch2;
switch(ch2)
{
case 1:
zhichengs="助教";
flag2=1;
break;
case 2:
zhichengs="讲师";
flag2=1;
break;
case 3:
zhichengs="副教授";
flag2=1;
break;
case 4:
zhichengs="教授";
flag2=1;
break;
default:
cout<<"\n输入错误!请重新输入 : ";
break;
}
if(flag2==1)
break;
}
flag2=0;
return zhichengs;
}
void input1()
{
xibu=choosexibu();
cout<<"\n请输入成员专业 : ";
cin>>zhuanye;
zhicheng=choosezhicheng();
}
void output11()
{
output111();
cout<<std::left<<setw(13)<<"系部"<<std::left<<setw(13)<<"专业"<<std::left<<setw(13)<<"职称\n"<<endl;
}
void output1()
{
output();
cout<<std::left<<setw(13)<<xibu<<std::left<<setw(13)<<zhuanye<<std::left<<setw(13)<<zhicheng<<"\n"<<endl;
}
void showtongji(int taa1,int taa2,int taa3,int taa4,int ta1,int ta2,int ta3,int ta4,int ta5,int ta6,int ta7,int ta8,int ta9,int ta10,int ta11,int ta12,int ta13)
{
taa1!=0?cout<<"\n助教人数为 : "<<taa1<<endl:cout<<"";
taa2!=0?cout<<"\n讲师人数为 : "<<taa2<<endl:cout<<"";
taa3!=0?cout<<"\n副教授人数为 : "<<taa3<<endl:cout<<"";
taa4!=0?cout<<"\n教授人数为 : "<<taa4<<endl:cout<<"";
ta1!=0?cout<<"\n机械系教师人数为 : "<<ta1<<endl:cout<<"";
ta2!=0?cout<<"\n计算机系教师人数为: "<<ta2<<endl:cout<<"";
ta3!=0?cout<<"\n电子系教师人数为 : "<<ta3<<endl:cout<<"";
ta4!=0?cout<<"\n土木系教师人数为 : "<<ta4<<endl:cout<<"";
ta5!=0?cout<<"\n城建系教师人数为 : "<<ta5<<endl:cout<<"";
ta6!=0?cout<<"\n艺设系教师人数为 : "<<ta6<<endl:cout<<"";
ta7!=0?cout<<"\n经管系教师人数为 : "<<ta7<<endl:cout<<"";
ta8!=0?cout<<"\n外国语系教师人数为: "<<ta8<<endl:cout<<"";
ta9!=0?cout<<"\n数理系教师人数为 : "<<ta9<<endl:cout<<"";
ta10!=0?cout<<"\n音乐系教师人数为 : "<<ta10<<endl:cout<<"";
ta11!=0?cout<<"\n文法系教师人数为 : "<<ta11<<endl:cout<<"";
ta12!=0?cout<<"\n生化系教师人数为 : "<<ta12<<endl:cout<<"";
ta13!=0?cout<<"\n软件系教师人数为 : "<<ta13<<endl:cout<<"";
}
};
class Tea_Manage
{
Teacher Tea[Number];
int top1;
public:
Tea_Manage()
{
top1=0;
duqu();
}
void show();
void add();
void choose1();
void choose2();
void choose3();
void chaozhao();
void shanchu();
void shanchu11();
void xiugai();
void showall();
void tongji();
void baocun();
void duqu();
};
Tea_Manage t;
void Teacher_caidan()
{
system("color 3e");
system("cls");
cout<<"\n\n *********欢迎进入教师管理系统*********\n"<<endl;
caidan();
int test,flag=0;
cout<<"\n请输入您的选择 : ";
while(1)
{
cin>>test;
switch(test)
{
case 0:
zhucaidan();
flag=1;
break;
case 1:
system("cls");
t.add();
flag=1;
break;
case 2:
system("cls");
t.chaozhao();
flag=1;
break;
case 3:
system("cls");
t.shanchu();
flag=1;
break;
case 4:
system("cls");
t.xiugai();
flag=1;
break;
case 5:
system("cls");
t.showall();
flag=1;
break;
case 6:
system("cls");
t.tongji();
flag=1;
break;
case 7:
system("cls");
cout<<"感谢使用^-^"<<endl;
exit(0);
default:
cout<<"\n输入错误!!请重新输入 : ";
break;
}
if(flag==1)
break;
}
flag=0;
}
void Tea_Manage::show()
{
cout<<"\n当前系统为空!是否添加信息?\n\n1:是 2:返回上一级\n\n请输入选择 : ";
int aa;
while(1)
{
cin>>aa;
switch(aa)
{
case 1:
add();
return;
case 2:
Teacher_caidan();
return;
default:
cout<<"\n输入失败请重新输入 : ";
break;
}
}
}
void Tea_Manage::choose1()
{
int aaa;
cout<<"是否继续查找?\n\n1:继续 2:返回上一级\n\n请输入选择 : ";
while(1)
{
cin>>aaa;
switch(aaa)
{
case 1:
system("cls");
chaozhao();
return;
case 2:
system("cls");
Teacher_caidan();
return;
default:
cout<<"\n输入失败请重新输入 : ";
break;
}
}
}
void Tea_Manage::choose2()
{
int aaa,flag=1;
cout<<"\n是否继续?\n\n1:继续 2:返回上一级\n\n请输入选择 : ";
while(1)
{
cin>>aaa;
switch(aaa)
{
case 1:
xiugai();
return ;
case 2:
Teacher_caidan();
return ;
default:
cout<<"n输入错误!请重新输入 : \n";
break;
}
if(flag==1)
{
flag=0;
break;
}
}
}
void Tea_Manage::choose3()
{
int aaa;
cout<<"\n是否继续?\n\n1:继续 2:返回上一级\n\n请输入选择 : ";
while(1)
{
cin>>aaa;
switch(aaa)
{
case 1:
shanchu();
return;
case 2:
Teacher_caidan();
return;
default:
cout<<"\n输入失败请重新输入 : ";
break;
}
}
}
void Tea_Manage::add()
{
system("cls");
Teacher t;
if(top1>=Number)
{
cout<<"用户已满!\n无法添加!!!"<<endl;
return;
}
else
{
cout<<"\n输入新添加的人员的信息\n\n 输入0结束输入"<<endl;
string ch;
int flag=1,ans=0;
while(1)
{
cout<<"\n请输入成员编号 : ";
cin>>ch;
if(ch[0]=='0'&&ch.length()==1)
break;
for(int i=0; i<top1; i++)
{
if(ch==Tea[i].number)
{
flag=0;
break;
}
else
flag=1;
}
if(flag==0)
cout<<"\n该编号的人员已存在!\n";
else
{
t.setinfo(ch);
t.input();
t.input1();
Tea[top1]=t;
top1++;
flag=1;
ans++;
cout<<"\n成功添加此人信息!"<<endl;
}
}
cout<<"\n共添加了"<<ans<<"人"<<endl;
cout<<"\n是否继续?\n\n1:继续 2:保存并返回上一级 0:返回主菜单\n\n请输入选择 : ";
int aa;
while(1)
{
cin>>aa;
switch(aa)
{
case 0:
system("cls");