爱问知识人 爱问教育 医院库

C/C 职工信息管理系统。怎么办?

首页

C/C 职工信息管理系统。怎么办?


        

提交回答

全部答案

    2018-08-27 01:34:47
  •   "# include 
    # include
    # include
    # include
    # include
    using namespace std;
    struct worker_inf
    {
    int month; //月份
    int code; //工人编号
    string name; //姓名
    float get[4]; //基本工资,津贴,房帖,交通补贴
    float pay[4]; //房租,储蓄,交通费,会费
    float tax; //个人所得税
    float theory_num; //应发书
    float reduce_num; //应扣数
    float practice_num; //实发数
    worker_inf *next;
    };
    /////////////////////////////////////////////////////////////////
    class worker //定义职工类
    {
    private:
    worker_inf *head;
    void print(worker_inf *); //输出一条指定职工的工资记录,并返回该记录的指针
    worker_inf *find(int); //查找条例条件的记录,并返回该记录的指针
    public:
    worker(){head=NULL;}
    worker_inf *get_head(){return head;}
    int listcount(); //统计当前链表的记录总数,并返回1个整数
    void additem(int month,int code,string name,float get[4],float pay[4]); //增加一条工资记录表尾
    void removeitem(int); //删掉一条指定职工的工资记录
    int menu(); //修改某职工工资的菜单
    void changemonth(); //修改月份
    void changeitem(int); //修改职工的工资信息
    void list(); //输出当月全体职工的工资信息
    void search(int); //输出指定编号职工的工资信息
    float tax_num(); //计算职工个人所得税
    float theorynumber(); //计算应发工资
    float reducenumber(); //计算应扣工资
    float practicenumber(); //计算实发工资
    };
    //////////////////////////////////////////////////////////////////
    int worker::listcount() //统计当前链表数,并返回1个整数
    {

    if(!head)return 0;
    worker_inf *p=head;
    int n=0;
    while(p)
    {n ;p=p->next;}
    return n;
    }
    //////////////////////////////////////////////////////////////////
    void worker::additem(int month,int code,string name,float get[4],float pay[4]) //增加一条工资记录到表尾
    {
    if(!head)
    {
    head=new worker_inf;
    for(int i=0;iget[i]=get[i];
    head->pay[i]=pay[i];
    }
    head->code=code;
    head->month=month;
    head->name=name;
    head->next=NULL;
    return;
    }
    worker_inf *t=head;
    while(t && t->code!=code)
    t=t->next;
    if(t)
    {
    coutnext)p=p->next;
    worker_inf *p1=new worker_inf;
    p1->code=code;
    for(int i=0;iget[i]=get[i];
    p1->pay[i]=pay[i];
    }
    p1->code=code;
    p1->month=month;
    p1->name=name;
    p1->next=NULL;
    p->next=p1;
    return;
    }
    ////////////////////////////////////////////////////////////////////
    void worker::removeitem(int code) //删掉一条指定职工的工资记录
    {
    worker_inf *t=find(code);
    if(!t)return;
    worker_inf *p=head;//假如要删掉的记录位于表头
    if(head==t)
    {
    head=head->next;
    delete p;
    coutnext!=t)p=p->next;
    worker_inf *p1=p->next;
    p->next=p1->next;
    delete p1;
    cout>select;
    if(select9)
    {
    cout>select;
    }
    return select;
    }
    /////////////////////////////////////////////////////////////////
    int menu();
    void worker::changeitem(int code) //修改某职工部分工资信息
    {
    worker_inf *p=find(code);
    if(!p){cout>m;
    int n;
    if(selectget[n]=m;}
    else{
    n=select-5;
    p->pay[n]=m;}
    tax_num();
    theorynumber();
    reducenumber();
    practicenumber();
    coutmonth==12)p->month=1;
    else
    p->month ;
    p=p->next;
    }
    }
    //////////////////////////////////////////////////////////////////////
    void worker::print(worker_inf *p)//输出worker_inf制定的记录
    {
    cout。
      precision(0);
    coutnext;
    }
    coutcode==code)break;
    p=p->next;
    }
    if(!p)
    {
    coutget[i];
    p->theory_num=sum;
    p=p->next;
    }
    return 0;
    }
    //////////////////////////////////////////////////////////////////
    float worker::tax_num() //计算个人所得税
    {
    if(listcount==0)
    {
    couttheory_num;
    if(stheory_num=0;
    else if(stheory_num=(s-800)*0。
      05;
    else if(stheory_num=(s-2000)*0。1 60;
    else p->theory_num=(s-5000)*0。2 360;
    p=p->next;
    }
    return 0;
    }
    ///////////////////////////////////////////////////////////////////////
    float worker::reducenumber() //计算应扣数
    {
    int i;
    if(listcount==0)
    {
    coutpay[i];
    p->reduce_num=p->tax sum;
    p=p->next;
    }
    return 0;
    }
    /////////////////////////////////////////////////////////////////////////
    float worker::practicenumber() //计算实发数
    {
    if(listcount()==0)
    {
    couttheory_num;
    b=p->reduce_num;
    p->practice_num=a-b;
    p=p->next;
    }
    return 0;
    }
    ////////////////////////////////////////////////////////////////////////////
    worker worker; //定义全局变量
    int menu()
    {
    int select=-1;
    cout>select;
    return select;
    }
    /////////////////////////////////////////////////////////////////////////////
    char exit()
    {
    char s;
    cout>s;
    return s;
    }
    //////////////////////////////////////////////////////////////////////////////
    void input(int *month,int*code,string *name,float get[4],float pay[4]) //输入职工信息
    {
    cout>*month;
    cin>>*code;
    if(*code==-1)return;
    cin>>*name>>get[0]>>get[1]>>get[2]>>get[3]>>pay[0]>>pay[1]>>pay[2]>>pay[3];
    return;
    }
    ///////////////////////////////////////////////////////////////////////////////
    void addnew() //增加记录
    {
    int month=0,code=0;float get[4]={0},pay[4]={0};
    string name="";
    cout>code;
    if(code==-1)continue;
    worker。
      search(code);
    }while(code!=-1);
    return;
    }
    /////////////////////////////////////////////////////////////////////////////////
    void dodelete() //删掉职工信息
    {
    cout>code;
    if(code==-1)continue;
    worker。
      removeitem(code);
    }while(code!=-1);
    return;
    }
    ///////////////////////////////////////////////////////////////////////////////////
    void domodify() //修改职工信息
    {
    int code;
    cout>code;
    if(code==-1)return;
    else
    worker。
      changeitem(code);
    }
    return;
    }
    ///////////////////////////////////////////////////////////////////////////////////
    void SaveFilethism()//将当月工资信息写入文件
    {
    worker_inf *p;
    char name[20];
    fstream iofile;
    int i=0;
    iofile。
      open("Worker_5th。dat",ios::out|ios::binary);
    if(!iofile)
    {
    cerrname。copy(name,20,0);
    name[p->name。
      length()]=0;
    iofile。write((char *) &p->code,sizeof(int));
    iofile。write((char *) &p->month,sizeof(int));
    iofile。
      write((char *) name,20);
    for(int i=0;iget[i],sizeof(float));
    }
    for(int j=0;jpay[j],sizeof(float));
    }
    p=p->next;
    }
    iofile。
      close();
    cout<<"成功将工资信息存入文件"<}
    ////////////////////////////////////////////////////////////////////////
    void Loadfilethism() //读取当月全体职工的工资信息文件
    {
    int month,code;
    char name[20]="";
    float get[4],pay[4];
    fstream iofile;
    int i=0;
    iofile。
      open("Worker_5th。dat",ios::in|ios::binary);
    if(!iofile)
    {
    cout<<"数据文件不存在,请先建立该文件"< return;
    }
    if(iofile。
      eof())
    {
    cout<<"数据库为空,请先增加数据"< iofile。close();
    }
    else
    {
    while(iofile。
      peek()!=EOF)//peek()是取文件当前指针,EOF是文件尾标符
    {
    iofile。read((char *) &code,sizeof(int));
    iofile。
      read((char *) &month,sizeof(int));
    iofile。read((char *) name,20);
    for(int i=0;i<4;i )
    {
    iofile。
      read((char *) &get[i],sizeof(float));
    } for(int j=0;j<4;j )
    {
    iofile。read((char *) &pay[j],sizeof(float));
    }
    worker。
      additem(code,month,name,get,pay);
    }
    worker。tax_num();
    worker。theorynumber();
    worker。
      reducenumber();
    worker。practicenumber();
    iofile。close();
    cout<<"成功导入工资信息"< }
    }
    /////////////////////////////////////////////////////////////////////////
    void list()
    {
    worker。
      list();
    }
    /////////////////////////////////////////////////////////////////////////
    int main()
    {
    cout<<"******************欢迎进职工工资管理系统(System)*******************"< int select;
    char s;
    while(1)
    {
    select=menu();
    switch(select)
    {
    case 0: //退出程序
    s=exit();
    if(s=='y'||s=='Y') return 0;
    break;
    case 1: //增加新记录
    addnew();
    break;
    case 2: //删掉记录
    dodelete();
    break;
    case 3: //修改记录
    domodify();
    break;
    case 4: //按条件查找
    dofind();
    break;
    case 5: //列出全部记录
    list();
    break;
    case 6: //导入当月职工记录
    Loadfilethism();
    break;
    case 7: //将职工记录存入磁盘
    SaveFilethism();
    break;
    default:
    cout<<"此输入无效!"< }
    }
    return 0;
    }"。
      

    谁***

    2018-08-27 01:34:47

类似问题

换一换

相关推荐

正在加载...
最新问答 推荐信息 热门专题 热点推荐
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200

热点检索

  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
返回
顶部
帮助 意见
反馈

确定举报此问题

举报原因(必选):