?? c++高校人事管理系統(tǒng).txt
字號:
這是我們搞的高校人事管理系統(tǒng) 看看吧!!
#include<iostream.h>
#include<string.h>
#include<fstream.h>
#include<iomanip.h>
class person
{
private:
int no;
char type[20];
char name[20];
char sex[10];
int age;
char time1[20];
char time2[20];
char pos[20];
char techpos[20];
char party[20];
char study[30];
person *mynext;
public:
person(int nnum,char ntype[],char nname[],char nsex[],int nage,char ntime1[],char ntime2[],char npos[],char ntechpos[],char nparty[],char nstudy[])
{
no=nnum;
strcpy(type,ntype);
strcpy(name,nname);
strcpy(sex,nsex);
strcpy(time1,ntime1);
age=nage;
strcpy(time2,ntime2);
strcpy(pos,npos);
strcpy(techpos,ntechpos);
strcpy(party,nparty);
strcpy(study,nstudy);
mynext=NULL;
}
person(int nnum,char ntype[],char nname[],char nsex[],int nage,char ntime1[],char ntime2[],
char npos[],char ntechpos[],char nparty[],char nstudy[],person *next)
/*某高校,主要人員有:在職人員(行政人員、教師、一般員工)、退休人員、返聘人員和臨時工。
現(xiàn)在,需要存儲這些人員的人事檔案信息:編號、姓名、性別、年齡、職務(wù)、職稱、政治面貌、最高學(xué)歷、任職時間、來院時間。
*/
{
no=nnum;
strcpy(type,ntype);
strcpy(name,nname);
strcpy(sex,nsex);
strcpy(time1,ntime1);
age=nage;
strcpy(time2,ntime2);
strcpy(pos,npos);
strcpy(techpos,ntechpos);
strcpy(party,nparty);
strcpy(study,nstudy);
mynext=next;
}
void setnext(person *next)// //
{
mynext=next;
}
person *getnext()
{
return mynext;
}
int getnum()
{
return no;
}
char *getname()
{
return name;
}
char *getsex()
{
return sex;
}
char *getpos()
{
return pos;
}
char *gettechpos()
{
return techpos;
}
char *gettime1()
{
return time1;
}
char *gettime2()
{
return time2;
}
char *getparty()
{
return party;
}
char *getstudy()
{
return study;
}
int getage()
{
return age;
}
void getag(int as)
{
age=as;
}
char *gettype()
{
return type;
}
};
class School
{
private:
person *myfirst;
int firstnum;
public:
School()
{
myfirst=NULL;
}
School(int nnu,char ntyp[],char nnam[],char nse[],int nag,char ntim1[],char ntim2[],char npo[],char ntechpo[],char npart[],char nstud[])
{
myfirst=new person(nnu,ntyp,nnam,nse,nag,ntim1,ntim2,npo,ntechpo,npart,nstud);
}
void insertatlast(int nnum,char ntype[],char nname[],char nsex[],int nage,char ntime1[],char ntime2[],char npos[],char ntechpos[],char nparty[],char nstudy[])
// //
{
person *next=myfirst;
if(next==NULL)
myfirst=new person(nnum,ntype,nname,nsex,nage,ntime1,ntime2,npos,ntechpos,nparty,nstudy);
else
{
while(next->getnext()!=NULL)
next=next->getnext();
next->setnext(new person(nnum,ntype,nname,nsex,nage,ntime1,ntime2,npos,ntechpos,nparty,nstudy,next->getnext()));
}
}
//-------------------------------------------------------------
void printf(int r)
{
int nage;
char ntype[20],nname[20],nsex[20],ntime1[20],ntime2[20],npos[20],ntechpos[20],nparty[20],nstudy[20];
cout<<"請輸入編號為"<<r<<"的成員的信息"<<endl;
cout<<"輸入職工分類碼[行政人員,教師,一般員工,退休人員,返聘人員,臨時工]:"<<endl;
cin>>ntype;
cout<<"輸入姓名:"<<endl;
cin>>nname;
cout<<"輸入性別:"<<endl;
cin>>nsex;
cout<<"輸入年齡:"<<endl;
cin>>nage;
cout<<"參加工作時間:"<<endl;
cin>>ntime1;
cout<<"輸入來院時間:"<<endl;
cin>>ntime2;
cout<<"輸入職務(wù)[無,科級,處級,地級]:"<<endl;
cin>>npos;
cout<<"輸入職稱[無,初級,中級,高級]:"<<endl;
cin>>ntechpos;
cout<<"輸入加入黨派[群眾,中共黨員,民主黨派]:"<<endl;
cin>>nparty;
cout<<"輸入學(xué)歷[小學(xué),初中,高中,大專,大學(xué),碩士,博士]:"<<endl;
cin>>nstudy;
insertatlast(r,ntype,nname,nsex,nage,ntime1,ntime2,npos,ntechpos,nparty,nstudy);
}
void printf1(person *ahead)
{
cout<<"編號:"<<setiosflags(ios::left)<<setw(26)<<ahead->getnum()<<"姓名:"<<ahead->getname()<<endl;
cout<<"性別:"<<setiosflags(ios::left)<<setw(26)<<ahead->getsex()<<"年齡:"<<ahead->getage()<<endl;
cout<<"職工類型:"<<setiosflags(ios::left)<<setw(22)<<ahead->gettype()<<"職務(wù):"<<ahead->getpos()<<endl;
cout<<"職稱:"<<setiosflags(ios::left)<<setw(26)<<ahead->gettechpos()<<"學(xué)歷:"<<ahead->getstudy()<<endl;
cout<<"政治面貌:"<<setiosflags(ios::left)<<setw(22)<<ahead->getparty()<<"來院時間:"<<ahead->gettime1()<<endl;
cout<<"參加工作時間:"<<ahead->gettime2()<<endl;
}
//---------------------------------------------
void pri()
{
person *ahead=myfirst;
cout<<"編號姓名 性別 年齡 職工類型 職務(wù) 職稱 學(xué)歷 政治面貌 來院時間 參加工作時間\n";
while(ahead!=NULL)
{
cout<<setiosflags(ios::left)<<setw(4)<<ahead->getnum()<<setiosflags(ios::left)<<setw(6)<<ahead->getname()
<<setiosflags(ios::left)<<setw(5)<<ahead->getsex()<<setiosflags(ios::left)<<setw(4)<<ahead->getage()
<<setiosflags(ios::left)<<setw(10)<<ahead->gettype()<<setiosflags(ios::left)<<setw(6)<<ahead->getpos()
<<setiosflags(ios::left)<<setw(6)<<ahead->gettechpos()<<setiosflags(ios::left)<<setw(6)<<ahead->getstudy()
<<setiosflags(ios::left)<<setw(9)<<ahead->getparty()<<setiosflags(ios::left)<<setw(12)<<ahead->gettime1()
<<ahead->gettime2()<<endl;
ahead=ahead->getnext();
}
}
void add()
{
int i,a,b;
person *p1=myfirst;
if(p1==NULL)
{
cout<<"請輸入編號:";
cin>>i;
printf(i);
}
else
{
if(p1->getnext()==NULL)
{
a=p1->getnum()+1;
printf(a);
}
else
{
while(p1->getnext()!=NULL)
{
p1=p1->getnext();
}
b=p1->getnum()+1;
printf(b);
}
}
}
bool removedatnum( )
{
int bh;
person *ahead=myfirst;
person *follow=ahead;
cout<<"請輸入要刪除人員的編號:";
cin>>bh;
if(ahead==NULL)
return false;
else
if(ahead->getnum()==bh)
{
myfirst=myfirst->getnext();
cout<<"編號為"<<bh<<"的成員以被刪除"<<endl;
delete ahead;
return true;
}
else
{
ahead=ahead->getnext();
while(ahead!=NULL)
{
if(ahead->getnum()==bh)
{
follow->setnext(ahead->getnext());
cout<<"編號為"<<bh<<"的成員以被刪除\n";
delete ahead;
return true;
}
follow=ahead;
ahead=ahead->getnext();
}
cout<<"要刪除的成員不存在!"<<endl;
return false;
}
}
bool find1()
{
int id;
person *ahead=myfirst;
person *follow=ahead;
cout<<"請輸入編號:"<<endl;
cin>>id;
cout<<"**********************************"<<endl;
if(ahead==NULL)
{
cout<<"無人員信息!"<<endl;
return false;
}
else
{
while(ahead!=NULL)
{
if(ahead->getnum()==id)
{
printf1(ahead);
return true;
}
else
{
follow=ahead;
ahead=ahead->getnext();
}
}
cout<<"無此人信息:"<<endl;
return false;
}
}
bool find2( )
{
char nm[20];
person *ahead=myfirst;
person *follow=ahead;
cout<<"輸入姓名";
cin>>nm;
cout<<"**********************************"<<endl;
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<<"請選擇統(tǒng)計對象: "<<endl;
cout<<" 1 在職人數(shù)"<<endl;
cout<<" 2 黨員人數(shù)"<<endl;
cout<<" 3 女工人數(shù)"<<endl;
cout<<" 4 高學(xué)歷高職稱人數(shù)"<<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<<"在職人數(shù):"<<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<<"中共黨員人數(shù):"<<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<<"女職工人數(shù):"<<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<<"高學(xué)歷高職稱人數(shù):"<<sz<<endl;
};
break;
}
cout<<"統(tǒng)計結(jié)果:"<<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<<"請選擇要修改的內(nèi)容:"<<endl;
cout<<" 1:姓名 2:性別 3:年齡 4:職工類型 5:職務(wù)"<<endl;
cout<<" 6:職稱 7:學(xué)歷 8:政治面貌 9:來院時間 10:參加工作時間"<<endl;
cout<<" 選擇(1-10):";
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<<"請輸入職務(wù):";
cin>>ty;
strcpy(ahead->getpos(),ty);
};
break;
case 6:{
cout<<"請輸入職稱:";
cin>>ty;
strcpy(ahead->gettechpos(),ty);
};
break;
case 7:{
cout<<"請輸入學(xué)歷:";
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<<"請輸入?yún)⒓庸ぷ鲿r間:";
cin>>ty;
strcpy(ahead->gettime2(),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];
ifstream fperson;
fperson.open("person.txt",ios::in);
while(fperson.good())
{
fperson>>nnum>>ntype>>nname>>nsex>>nage>>ntime1>>ntime2>>npos>>ntechpos>>nparty>>nstudy;
insertatlast(nnum,ntype,nname,nsex,nage,ntime1,ntime2,npos,ntechpos,nparty,nstudy);
}
fperson.close();
cout<<"\n人員和相關(guān)數(shù)據(jù)已經(jīng)裝入.....\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"<<p->getage()<<"\t"<<p->gettime1()<<"\t"<<p->gettime2()<<"\t"<<p->getpos()<<"\t"<<p->gettechpos()<<"\t"<<p->getparty()<<"\t"<<p->getstudy();
fperson<<endl;
p=p->getnext();
}
fperson.close();
cout<<"保存數(shù)據(jù)已經(jīng)完成"<<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<<"☆☆☆高校人事管理系統(tǒng)☆☆☆"<<endl;
cout<<" 1--增加人員資料"<<endl;
cout<<" 2--刪除人員信息"<<endl;
cout<<" 3--修改人員信息"<<endl;
cout<<" 4--查詢?nèi)藛T信息"<<endl;
cout<<" 5--統(tǒng)計人員信息"<<endl;
cout<<" 6--數(shù)據(jù)存盤"<<endl;
cout<<" 7--數(shù)據(jù)裝入"<<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);
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -