📄 -
字号:
if(ahead==NULL)
{
cout<<"无人员信息"<<endl;
return false;
}
else
{
while(ahead!=NULL)
{
if(strcmp(ahead->getname(),nm)==0)
{
printf1(ahead);
return true;
}
else
{
follow=ahead;
ahead=ahead->getnext();
}
}
cout<<"查无此人:"<<endl;
return false;
}
}
//--------------------------------------------------------------------------------
void stat()//定义函数//
{
int xx,sz=0;
cout<<"请选择统计对象: "<<endl;
cout<<" 1 在职人数"<<endl;
cout<<" 2 党员人数"<<endl;
cout<<" 3 女工人数"<<endl;
cout<<" 4 高学历高职称人数"<<endl;
cout<<" 请选择:";
cin>>xx;
switch(xx)
{
case 1: {
person *ahead=myfirst;
if(ahead==NULL)
cout<<"无人员信息"<<endl;
else
{
while(ahead!=NULL)
{
if(strcmp(ahead->gettype(),"行政人员")==0||strcmp(ahead->gettype(),"教师")==0||strcmp(ahead->gettype(),"一般员工")==0)
{
ahead=ahead->getnext();
sz++;
}
else
ahead=ahead->getnext();
}
}
cout<<"在职人数:"<<sz<<endl;
};
break;
case 2:{
person *ahead=myfirst;
if(ahead==NULL)
cout<<"无人员信息\n";
else
{
while(ahead!=NULL)
{
if(strcmp(ahead->getparty(),"中共党员")==0)
{
ahead=ahead->getnext();
sz++;
}
else
ahead=ahead->getnext();
}
}
cout<<"中共党员人数:"<<sz<<endl;
};
break;
case 3:{
person *ahead=myfirst;
person *follow=ahead;
if(ahead==NULL)
cout<<"无人员信息\n";
else
{
while(ahead!=NULL)
{
if(strcmp(ahead->getsex(),"女")==0)
{
ahead=ahead->getnext();
sz++;
}
else
ahead=ahead->getnext();
}
}
cout<<"女职工人数:"<<sz<<endl;
};
break;
case 4:{
person *ahead=myfirst;
person *follow=ahead;
if(ahead==NULL)
cout<<"无人员信息"<<endl;
else
{
while(ahead!=NULL)
{
if(strcmp(ahead->getstudy(),"博士")==0||strcmp(ahead->getstudy(),"硕士")==0&&strcmp(ahead->gettechpos(),"高级")==0)
{
ahead=ahead->getnext();
sz++;
}
else
ahead=ahead->getnext();
}
}
cout<<"高学历高职称人数:"<<sz<<endl;
};
break;
}
cout<<"统计结果:"<<sz<<endl;
}
bool upperson()
{
int iid;
person *ahead=myfirst;
person *follow=ahead;
cout<<"请输入要修改人员的编号:";
cin>>iid;
if(ahead==NULL)
{
cout<<"无人员信息"<<endl;
return false;
}
else
{
while(ahead!=NULL)
{
if(ahead->getnum()==iid)
{
printf1(ahead);
int nu=-1;
for(int i=1;nu!=0;i++)
{
int ml;
int mll;
char ty[30];
cout<<"请选择要修改的内容:"<<endl;
cout<<" 1:姓名 2:性别 3:年龄 4:职工类型 5:职务"<<endl;
cout<<" 6:职称 7:学历 8:政治面貌 9:来院时间 10:参加工作时间"<<endl;
cout<<"11:联系地址 12:联系电话"<<endl;
cout<<" 选择(1-12):";
cin>>ml;
switch(ml)
{
case 1:{
cout<<"请输入姓名:";
cin>>ty;
strcpy(follow->getname(),ty);
};
break;
case 2:{
cout<<"请输入性别:";
cin>>ty;
strcpy(ahead->getsex(),ty);
};
break;
case 3:{
cout<<"请输入年龄:";
cin>>mll;
ahead->getag(mll);
};
break;
case 4:{
cout<<"请输入职工类型:";
cin>>ty;
strcpy(ahead->gettype(),ty);
};
break;
case 5:{
cout<<"请输入职务:";
cin>>ty;
strcpy(ahead->getpos(),ty);
};
break;
case 6:{
cout<<"请输入职称:";
cin>>ty;
strcpy(ahead->gettechpos(),ty);
};
break;
case 7:{
cout<<"请输入学历:";
cin>>ty;
strcpy(ahead->getstudy(),ty);
};
break;
case 8:{
cout<<"请输入政治面貌:";
cin>>ty;
strcpy(ahead->getparty(),ty);
};
break;
case 9:{
cout<<"请输入来院时间:";
cin>>ty;
strcpy(ahead->gettime1(),ty);
};
break;
case 10:{
cout<<"请输入参加工作时间:";
cin>>ty;
strcpy(ahead->gettime2(),ty);
};
break;
case 11:{
cout<<"请输入家庭地址:";
cin>>ty;
strcpy(ahead->getadr(),ty);
};
break;
case 12:{
cout<<"请输入联系电话:";
cin>>ty;
strcpy(ahead->gettel(),ty);
};
break;
}
return true;
}
}
else
{
ahead=ahead->getnext();
follow=ahead;
}
}
cout<<"没有此人"<<endl;
return false;
}
}
void load()
{
int nnum,nage;
char ntype[20],nname[20],nsex[20],ntime1[20],ntime2[20],npos[20],ntechpos[20],nparty[20],nstudy[20],nadr[80],ntel[11];
ifstream fperson;
fperson.open("person.txt",ios::in);
while(fperson.good())
{
fperson>>nnum>>ntype>>nname>>nsex>>nage>>ntime1>>ntime2>>npos>>ntechpos>>nparty>>nstudy>>nadr>>ntel;
insertatlast(nnum,ntype,nname,nsex,nage,ntime1,ntime2,npos,ntechpos,nparty,nstudy,nadr,ntel);
}
fperson.close();
cout<<"\n人员和相关数据已经装入.....\n";
}
void save()
{
ofstream fperson;
fperson.open("person.txt",ios::out);
person *p=myfirst;
while(p)
{
fperson<<p->getnum()<<"\t"<<p->gettype()<<"\t"<<p->getname()<<"\t"<<p->getsex()<<"\t"<<"\n"<<p->getage()<<"\t"<<p->gettime1()<<"\t"<<p->gettime2()<<"\t"<<"\n"<<p->getpos()<<"\t"<<p->gettechpos()<<"\t"<<p->getparty()<<"\t"<<p->getstudy()<<"\t"<<p->getadr()<<"\t"<<p->gettel();
fperson<<endl;
p=p->getnext();
}
fperson.close();
cout<<"保存数据已经完成"<<endl;
}
~School()
{
person *next=myfirst,*temp;
while(next!=NULL)
{
temp=next;
next=next->getnext();
delete temp;
}
myfirst=NULL;
}
};
void main()
{
School obj;
int c;
do
{
cout<<"☆☆☆制作人:啊生 QQ:308744373☆☆☆"<<endl;
cout<<"☆☆☆老师通信录管理系统☆☆☆(要显示先按7装入)"<<endl;
cout<<" 1--增加人员资料"<<endl;//结构体
cout<<" 2--删除人员信息"<<endl;
cout<<" 3--修改人员信息"<<endl;
cout<<" 4--查询人员信息"<<endl;
cout<<" 5--统计人员信息"<<endl;
cout<<" 6--数据存盘"<<endl;
cout<<" 7--数据装入"<<endl;
cout<<" 8--显示所有信息"<<endl;
cout<<" 9--退出 请选择(1-9):";
cin>>c;
switch(c)
{
case 1:obj.add(); break;
case 2:obj.removedatnum(); break;
case 3:obj.upperson(); break;
case 4:{
int nm;
cout<<"1-通过编号。2-通过姓名。请选择:";
cin>>nm;
if(nm==1)
obj.find1();
else
obj.find2();
}; break;
case 5: obj.stat(); break;
case 6: obj.save(); break;
case 7: obj.load(); break;
case 8: obj.pri(); break;
}
}while(c!=9);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -