⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄

📁 高校人事管理程序
💻
字号:
#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)
 /*某高校,主要人员有:在职人员(行政人员、教师、一般员工)、退休人员、返聘人员和临时工。
 现在,需要存储这些人员的人事档案信息:编号、姓名、性别、年龄、职务、职称、政治面貌、最高学历、任职时间、来院时间。
*/ 


 {
  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<<"输入职务[无,科级,处级,地级]:"<<endl;
  cin>>npos;
  cout<<"输入职称[无,初级,中级,高级]:"<<endl;
  cin>>ntechpos;
  cout<<"输入加入党派[群众,中共党员,民主党派]:"<<endl;
  cin>>nparty;
  cout<<"输入学历[小学,初中,高中,大专,大学,硕士,博士]:"<<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()<<"职务:"<<ahead->getpos()<<endl;
  cout<<"职称:"<<setiosflags(ios::left)<<setw(26)<<ahead->gettechpos()<<"学历:"<<ahead->getstudy()<<endl;
  cout<<"政治面貌:"<<setiosflags(ios::left)<<setw(22)<<ahead->getparty()<<"来院时间:"<<ahead->gettime1()<<endl;
  cout<<"参加工作时间:"<<ahead->gettime2()<<endl;
 }

//--------------------------------------------- 
 void  pri()
 {
  person *ahead=myfirst;
  cout<<"编号姓名  性别 年龄  职工类型  职务  职称  学历  政治面貌   来院时间   参加工作时间\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<<"请选择统计对象: "<<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<<"   选择(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<<"请输入职务:";
                    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;
       }
       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人员和相关数据已经装入.....\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<<"保存数据已经完成"<<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<<"☆☆☆高校人事管理系统☆☆☆"<<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 + -