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

📄 -

📁 C++编的,很不错的,大家下载看看吧.不要错失良机哦.
💻
📖 第 1 页 / 共 2 页
字号:
#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];
 char adr[80];
 char tel[11];
 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[],char nadr[],char ntel[])
//定义各种变量,全局变量 
 {
  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);
  strcpy(adr,nadr);
  strcpy(tel,ntel);
  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[],char nadr[],char ntel[],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);
  strcpy(adr,nadr);
  strcpy(tel,ntel);

  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;
 }
 char *getadr()
 {
	 return adr;
 }
 char *gettel()
 {
	 return tel;
 }
};
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[],char nadr[],char ntel[])
 {
  myfirst=new person(nnu,ntyp,nnam,nse,nag,ntim1,ntim2,npo,ntechpo,npart,nstud,nadr,ntel);
 }
 
 void insertatlast(int nnum,char ntype[],char nname[],char nsex[],int nage,char ntime1[],char ntime2[],char npos[],char ntechpos[],char nparty[],char nstudy[],char nadr[],char ntel[])
 //   调用函数      //
 {
  person *next=myfirst;
  if(next==NULL)
   myfirst=new person(nnum,ntype,nname,nsex,nage,ntime1,ntime2,npos,ntechpos,nparty,nstudy,nadr,ntel);
  else
  {
   while(next->getnext()!=NULL)
    next=next->getnext();
   next->setnext(new person(nnum,ntype,nname,nsex,nage,ntime1,ntime2,npos,ntechpos,nparty,nstudy,nadr,ntel,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],nadr[80],ntel[11];
     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;
  cout<<"输入联系地址:"<<endl;
  cin>>nadr;
  cout<<"输入联系电话:"<<endl;
  cin>>ntel;
  insertatlast(r,ntype,nname,nsex,nage,ntime1,ntime2,npos,ntechpos,nparty,nstudy,nadr,ntel);
 }
 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()<<"家庭地址:"<<setiosflags(ios::left)<<setw(22)<<ahead->getadr()<<"联系电话:"<<ahead->gettel()<<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()<<'t'
    <<ahead->gettime2()<<setiosflags(ios::left)<<setw(30)<<ahead->getadr()<<ahead->gettel()<<endl;
   ahead=ahead->getnext();
  }
 }
 void add()//调用函数//
 {
  int i,a,b;
  person *p1=myfirst;
  if(p1==NULL)//p1为空
  {
   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;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -