员工工资管理系统源代码

合集下载

员工工资管理系统源代码

员工工资管理系统源代码

#include<stdio.h>#include<string.h>typedef struct{int basic;//基本工资int position;//岗位工资int subsidy;//津贴int wages;//奖金int sum;//总工资}money;typedef struct{char num[20];//职工号char name[20];//姓名int age;//年龄char sex[20];//性别money salary;//工资}employee;int Print_jinru();//账号密码输入void Fscan_information();//“职工信息.txt”文件写入void Print_staff();//全体员工void Print_empl1(char x[51]);//按职工号查询void Print_empl2(char s[51]);//按姓名查询void Print_MainInterface();//主界面void Print_Interface_1();//职工信息录入界面void Print_Interface_2();//职工信息查询界面void Print_Interface_3();//职工工资排序界面void Print_Interface_4();//职工总工资void Print_Interface_5();//文件读出void qsort(int l,int r);//快速排序void Print_delete(int t);//删除职工信息void Print_Interface_2_1(int t);//职工信息修改界面int fyanzheng(char s1[],char s2[]);//密码验证函数employee st[500];//记录职工信息的函数int n;//职工总数void main(){int x;employee em;printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@\n");printf("@@@@ 欢迎使用员工工资管理系统@@@@\n");printf("@@@@ 制作人:刘爽@@@@\n");printf("@@@@在使用中产生的任何问题,欢迎进行批评指正@@@@\n");printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@\n");printf("\n");printf("\n");printf("\n");if (Print_jinru()){Fscan_information();Print_MainInterface();}else return;}void Fscan_information(){FILE *fp;int i;if ((fp=fopen("职工信息.txt","r"))==NULL){printf("cannot open this file\n");return ;}fscanf(fp,"%d",&n);for (i=1;i<=n;i++){fscanf(fp,"%s%s%d%s%d%d%d",st[i].num,st[i].name,&st[i].age,st[i].sex,&st[i].salary.basic,&s t[i].salary.subsidy,&st[i].salary.wages);st[i].salary.sum=st[i].salary.basic+st[i].salary.subsidy+st[i].salary.wages;}fclose(fp);}int fyanzheng(char s1[],char s2[]){FILE *fp1,*fp2;char str1[40]="",str2[40]="",st;int t;if ((fp1=fopen("账号验证.in","r"))==NULL){printf("cannot open this file\n");return 0;}t=0;st=fgetc(fp1);while (st!='#'){str1[t]=st;t++;st=fgetc(fp1);}if ((fp2=fopen("密码验证.in","r"))==NULL){printf("cannot open this file\n");return 0;}t=0;st=fgetc(fp2);while (st!='#'){str2[t]=st;t++;st=fgetc(fp2);}fclose(fp1);fclose(fp2);if ((strcmp(str1,s1)==0)&&(strcmp(str2,s2)==0)) return 1;elsereturn 0;}int Print_jinru(){int f,d;char x[20],y[20];f=0;d=0;while(1){printf("请输入账号:");scanf("%s",x);getchar();printf("请输入密码:");scanf("%s",y);getchar();f=fyanzheng(x,y);if (d>3)printf("错误次数太多,退出系统\n");return 0;}if (f>0) break;else{printf("账号或密码输入错误,请重新输入\n");d++;}}printf("\n");printf("欢迎进入员工工资管理系统\n");return 1;}void Print_MainInterface(){int x;printf("\n");printf("*************************华丽的分割线*************************\n");printf("\n");printf("1.职工信息录入\n");printf("2.职工信息查询\n");printf("3.职工工资排序\n");printf("4.统计职工总工资\n");printf("5.保存到文件\n");printf("6.退出职工工资系统\n");printf("请选择所需操作:");scanf("%d",&x);if (x==1)Print_Interface_1();elseif (x==2)Print_Interface_2();elseif (x==3)Print_Interface_3();elseif (x==4)Print_Interface_4();elseif (x==5)Print_Interface_5();else{printf(" ****** **** **** * * ***** * *\n");printf("* * * * * * * * * * *\n");printf("* * * * * * * * * * *\n");printf(" ****** ******** ******** ** * * * *\n");printf(" * * * ** * * * *\n");printf(" * * * ** * * * *\n");printf(" ****** **** **** ** ***** ***** \n");//printf("233333333333333333333333333333333333333333333333333333\n");return;}else{printf("输入命令错误,返回主菜单(再乱输入我找人打你啊)\n");Print_MainInterface();}}void Print_Interface_1(){n++;if (n>500){printf("超出职工最大数\n");Print_MainInterface();}printf("\n");printf("*************************妖精的分割线*************************\n");printf("\n");printf("新建职工号:");scanf("%s",st[n].num);printf("姓名:");scanf("%s",st[n].name);printf("年龄:");scanf("%d",&st[n].age);printf("性别:");scanf("%s",st[n].sex);printf("基本工资:");scanf("%d",&st[n].salary.basic);printf("津贴:");scanf("%d",&st[n].salary.subsidy);printf("奖金:");scanf("%d",&st[n].salary.wages);st[n].salary.sum=st[n].salary.basic+st[n].salary.subsidy+st[n].salary.wages;printf("职工信息已成功录入\n");Print_MainInterface();}void Print_Interface_2(){int x;char s[50],y[50];printf("\n");printf("*************************逗比的分割线*************************\n");printf("\n");printf("1.查询所有职工\n");printf("2.按职工号查询\n");printf("3.按职工姓名查询\n");printf("4.返回主菜单\n");printf("请选择查找方式:\n");scanf("%d",&x);if (x==1)Print_staff();elseif (x==2){printf("请输入职工工号:");scanf("%s",y);Print_empl1(y);}elseif (x==3){printf("请输入职工姓名:");scanf("%s",s);Print_empl2(s);}elseif (x==4)Print_MainInterface();else{printf("输入命令错误,返回上一层\n");Print_Interface_2();}}void Print_Interface_3(){char ch[10];printf("\n");qsort(1,n);printf("排序完成!排序后结果请从查询全体职工处查看\n");Print_MainInterface();}void Print_Interface_4(){int i,All=0;char ch[10];printf("\n");for (i=1;i<=n;i++)All=All+st[i].salary.sum;printf("所有职工的总工资为:%d\n",All);printf("请输入任意字符并敲回车键返回主菜单\n");scanf("%s",&ch);Print_MainInterface();}void Print_Interface_5(){FILE *fp;char ch[10];int i;if ((fp=fopen("职工信息.txt","w"))==NULL){printf("cannot open this file\n");return ;}fprintf(fp,"%d\n",n);for (i=1;i<=n;i++)fprintf(fp,"%s %s %d %s %d %d %d\n",st[i].num,st[i].name,st[i].age,st[i].sex,st[i].salary.basic, st[i].salary.subsidy,st[i].salary.wages);fclose(fp);printf("\n");printf("已保存到文件\n");printf("\n");printf("请输入任意字符返回主菜单\n");scanf("%s",&ch);Print_MainInterface();}void Print_staff(){int i;printf("\n");printf("*************************帅比的分割线*************************");printf("\n");for (i=1;i<=n;i++){printf("职工工号:%s\n",st[i].num);printf("姓名:%s\n",st[i].name);printf("年龄:%d\n",st[i].age);printf("性别:%s\n",st[i].sex);printf("基本工资:%d\n",st[i].salary.basic);printf("津贴:%d\n",st[i].salary.subsidy);printf("奖金:%d\n",st[i].salary.wages);printf("总工资:%d\n",st[i].salary.sum);printf("\n");}printf("返回上一层\n");Print_Interface_2();}void Print_empl1(char x[]){int i,t,y,d=0;printf("\n");for (i=1;i<=n;i++)if (strcmp(x,st[i].num)==0){t=i;d=1;printf("职工工号:%s\n",st[i].num);printf("姓名:%s\n",st[i].name);printf("年龄:%d\n",st[i].age);printf("性别:%s\n",st[i].sex);printf("基本工资:%d\n",st[i].salary.basic);printf("津贴:%d\n",st[i].salary.subsidy);printf("奖金:%d\n",st[i].salary.wages);printf("总工资:%d\n",st[i].salary.sum);printf("\n");break;}if (d>0){printf("如需删除请按2,修改请按1,返回请按0\n");scanf("%d",&y);if (y==2)Print_delete(t);elseif (y==1)Print_Interface_2_1(t);elseif (y==0)Print_Interface_2();else{printf("输入命令错误,返回上一层(再乱输入我找人打你啊)\n");Print_Interface_2();}}else{printf("对不起,查无此人(本系统不包括路人甲乙丙,不要乱输-_-!)\n");printf("请重新选择查询方式\n");Print_Interface_2();}}void Print_empl2(char s[]){int i,t,x,y=0;printf("\n");for (i=1;i<=n;i++)if (strcmp(s,st[i].name)==0){t=i;y=1;printf("职工工号:%s\n",st[i].num);printf("姓名:%s\n",st[i].name);printf("年龄:%d\n",st[i].age);printf("性别:%s\n",st[i].sex);printf("基本工资:%d\n",st[i].salary.basic);printf("津贴:%d\n",st[i].salary.subsidy);printf("奖金:%d\n",st[i].salary.wages);printf("总工资:%d\n",st[i].salary.sum);printf("\n");break;}if (y>0){printf("如需删除请按2,修改请按1,返回请按0(再乱输入我找人打你啊)\n");scanf("%d",&x);if (x==2)Print_delete(t);elseif (x==1)Print_Interface_2_1(t);elseif (x==0)Print_Interface_2();else{printf("输入命令错误,返回上一层\n");Print_Interface_2();}}else{printf("对不起,查无此人(本系统不包括路人甲乙丙,不要乱输-_-!)\n");printf("请重新选择查询方式\n");Print_Interface_2();}}void Print_delete(int t){st[t].salary.sum=0;qsort(1,n);n--;printf("已删除该职工并排序,自动返回主菜单\n");Print_MainInterface();}void Print_Interface_2_1(int t){int x;printf("\n");printf("请选择以下选项:\n");printf("1.职工号\n");printf("2.姓名\n");printf("3.年龄\n");printf("4.性别\n");printf("5.基本工资\n");printf("6.津贴\n");printf("7.奖金\n");printf("8.返回上一层\n");printf("9.返回主菜单\n");scanf("%d",&x);switch(x){case 1:scanf("%s",st[t].num);break;case 2:scanf("%s",st[t].name);break;case 3:scanf("%d",st[t].age);break;case 4:scanf("%s",st[t].sex);break;case 5:scanf("%s",st[t].salary.basic);break;case 6:scanf("%d",st[t].salary.subsidy);break;case 7:scanf("%d",st[t].salary.wages);break;}st[t].salary.sum=st[t].salary.basic+st[t].salary.subsidy+st[t].salary.wages;if (x<=8)Print_Interface_2();elseif (x==9)Print_MainInterface();}void qsort(int l,int r){int i,j,mid;employee tt;i=l;j=r;mid=st[(l+r)/2].salary.sum;do{while (st[i].salary.sum>mid) i++;while (st[j].salary.sum<mid) j--;if (i<=j){tt=st[i];st[i]=st[j];st[j]=tt;i++;j--;}}while(i<=j);if (i<r) qsort(i,r);if (l<j) qsort(l,j);。

C++ 工资管理系统 源代码

C++ 工资管理系统 源代码

#include<iostream>#include<string>#include<fstream>#include<iomanip>using namespace std; double sum,avarage;int amount=0;int ab=0,cd=0,ef=0; ofstream *file[50];struct xinxi{double jiben;double zhiwu;double gangwei;double yiliao;double gongji;double sum;double sum1;double avarage;struct xinxi *next;};class worker{public:string name;string ID;double sum;double avarage;xinxi sc1;class worker *next; };void luru(worker *head); void search1(worker *head); void search2(worker *head); void xianshi(worker *head); void xiugai(worker *head); void chazhao(worker *head); void shanchu(worker *head); void tianjia(worker *head); void tongji(worker *head); void display();void read(worker *head); void dakai(worker *head);int main(){system("color ff");int x;//bool flag2=0;/*do{do{cin>>x;if(x>=0&&x<=10)flag2=1;else{cout<<"~~~~~~~~~~~~指令错误!!!~~~~~~~~~~"<<endl;cout<<"请选择相应数字进行操作"<<endl;}}while(flag2==0)*/worker *head=new worker;head->next=NULL;while(1){display();cin>>x;if(x==1){cout<<"***************此刻进行职工数据的录入*****************\n";luru(head);cout<<"输入的职工信息为:\n";xianshi(head);display(); //break;}else if(x==2){cout<<"***************此刻进行职工数据的点窜******************\n";xiugai(head);display();//break; //按姓名点窜}else if(x==3){cout<<"***************此刻进行所有职工信息的显示*****************\n";xianshi(head);display();//break; //显示数据}else if(x==4){char z;cout<<"*****************此刻进行所有职工信息查找**************\n";cout<<"请选择查询方式\n";cout<<"(1).姓名查询方式(2).ID查询方式\n";cin>>z;while(z!='1'&&z!='2'){cout<<"**************指令错误********************\n";cout<<"(1).姓名查询方式(2).ID查询方式\n";cin>>z;}switch(z){case '1': search1(head);break;//按姓名查询case '2': search2(head);break;//按学号查询}display();// break;}else if(x==5){cout<<"***************此刻进行指定的职工信息的删除*****************\n";shanchu(head);xianshi(head);display();//break; //删除}else if(x==6){cout<<"****************此刻进行指定的职工信息的添加******************\n";tianjia(head);xianshi(head);display();break;//添加}else if(x==7){cout<<"**********************此刻进行指定的职工信息的统计***************\n";tongji(head);display();// break;}else if(x==8){cout<<"**********************此刻进行指定的职工信息的保留************\n";read(head);display();// break;}else if(x==9){cout<<"************************此刻进行指定的职工信息的翻开****************\n";dakai(head);display();// break;}else{cout<<" ╔═══════════════════════════╗\n";cout<<" ║您已退出职工办理系统, 谢谢您的使用! ║\n";cout<<" ╚═══════════════════════════╝\n";cout<<endl;exit(0);break;}}return 0;}void display(){cout<<" ╔═══════════════════════════╗"<<endl;cout<<" ║☆职工办理系统☆║"<<endl;cout<<" ║═══════════════════════════║"<<endl;cout<<" ║║"<<endl;cout<<" ║(1)职工数据的录入║"<<endl;cout<<" ║(2)职工数据的点窜║"<<endl;cout<<" ║(3)显示职工信息║"<<endl;cout<<" ║(4)查询职工信息║"<<endl;cout<<" ║--(1)按姓名查询║"<<endl;cout<<" ║--(2)按ID查询║"<<endl;cout<<" ║--统计总成就和平均成就║"<<endl;cout<<" ║(5)职工信息的删除║"<<endl;cout<<" ║(6)职工信息的添加║"<<endl;cout<<" ║(7)职工信息的统计║"<<endl;cout<<" ║(8)保留职工信息║"<<endl;cout<<" ║(9〕翻开职工信息║"<<endl;cout<<" ║退出程序║"<<endl;cout<<" ║║"<<endl;cout<<" ║═══════════════════════════║"<<endl;cout<<" ║注:请输入相应括号里的阿拉伯数字来执行相关操作!║"<<endl;cout<<" ║要保留数据请先成立好指定文件:║"<<endl;cout<<" ║(D:\\职工办理系统\\职工信息.txt) ║"<<endl;cout<<" ╟------------------------------------------------------╢"<<endl;cout<<" ║===================谢谢您的使用=======================║"<<endl;cout<<" ╚═══════════════════════════╝"<<endl;cout<<" →请选择相应的数字进行操作: "<<endl;}////////////////////////////////显示学生数据void xianshi(worker *head){worker *work=head->next;cout<<" | name | ID |底子工资|职务工资|岗位津贴|医疗保险|公积金|总工资|平均工资|"<<endl;while(work!=NULL){cout<<" | "<<setw(4)<<(*work).name;cout<<" | "<<setw(4)<<(*work).ID;cout<<" | "<<setw(4)<<(*work).sc1.jiben;cout<<" | "<<setw(4)<<(*work).sc1.zhiwu;cout<<" | "<<setw(4)<<(*work).sc1.gangwei;cout<<" | "<<setw(4)<<(*work).sc1.yiliao;cout<<" | "<<setw(4)<<(*work).sc1.gongji;cout<<" | "<<setw(4)<<(*work).sc1.sum;cout<<" | "<<setw(4)<<(*work).sc1.avarage;cout<<" | "<<endl;work=work->next;}system("pause");}void read(worker *head){char a;worker *work=head->next;cout<<"此刻保留输入职工数据,是否继续操作(y/n)";cin>>a;ofstream outfile("D:\\职工办理系统\\职工信息.txt",ios::out);if(! outfile){cout<<"翻开文件错误\n";cout<<"要保留数据请先成立好指定文件:D:\\职工办理系统\\职工信息.txt\n";exit(0);}while(a!='n'){while(work!=NULL){outfile<<"****************第"<<amount<<"个职工的数据:***************\n";outfile<<" | name | ID |底子工资|职务工资|岗位津贴|医疗保险|公积金|总工资|平均工资|"<<endl;outfile<<" 职工信息: \n" <<" | "<<setw(4)<<(*work).name<<" | "<<setw(4)<<(*work).ID<<" | "<<setw(4)<<(*work).scongji <<"|"<<setw(4)<<(*work).sc1.sum<<"|"<<setw(4)<<(*work).sc1.avarage<<"|"<< endl;amount++;work=work->next;}break;}cout<<"......成功将学生数据保留到<职工信息.txt>中! ";outfile.close();}void dakai(worker *head){worker *work=head->next;ofstream ofile("D:\\职工办理系统\\职工信息.txt",ios::out);work=work->next;}void luru(worker *head){char c;int j=0;worker *p=head;file[j]=new ofstream("D:\\职工办理系统\\职工信息.txt",ios::app);do{worker *work=new worker;cout<<"请输入姓名:"<<setw(10);cin>>(*work).name;cout<<"请输入ID:"<<setw(10);cin>>(*work).ID;cout<<"请输入底子工资:"<<setw(2);cin>>(*work).sc1.jiben;cout<<"请输入职务工资:"<<setw(2);cin>>(*work).sc1.zhiwu;cout<<"请输入岗位津贴:"<<setw(2);cin>>(*work).sc1.gangwei;cout<<"请输入医疗保险:"<<setw(2);cin>>(*work).sc1.yiliao;cout<<"请输入公积金:"<<setw(2);cin>>(*work).sc1.gongji;(*work).sc1.sum=(*work).sc1.gangwei+(*work).sc1.gongji+(*work).sc1.yiliao+(*work).sc1.zhiw u+(*work).sc1.jiben;(*work).sc1.avarage=((*work).sc1.gangwei+(*work).sc1.gongji+(*work).sc1.yiliao+(*work).sc1. zhiwu+(*work).sc1.jiben)/5;(*work).sc1.sum1=(*work).sc1.gangwei+(*work).sc1.zhiwu+(*work).sc1.jiben;if((*work).sc1.sum1>=2000) ab++;if((*work).sc1.sum1>=1500&&(*work).sc1.sum1<2000) cd++;if((*work).sc1.sum1>=1000&&(*work).sc1.sum1<1500) ef++;work->next=p->next;p->next=work;amount++;cout<<"数据录入成功,想继续录入吗(y/n)"; cin>>c;p=p->next;while(c!='y'&&c!='n'){cout<<"指令错误<请输入y/n!>"<<endl;cout<<"数据录入成功,想继续录入吗(y/n)";cin>>c;}}while(c=='y');j++;cout<<"输入了"<<amount<<"个职工的信息."<<endl;}void search1(worker *head){char c;string name;do{worker*work=head->next;bool flag=0;cout<<"请输入要查找的职工的姓名:";cin>>name;do{if(work!=NULL&&name==(*work).name){flag=1;cout<<" | name | ID |底子工资|职务工资|岗位津贴|医疗保险|公积金|总工资|平均工资|"<<endl;cout<<" | "<<setw(4)<<(*work).name;cout<<" | "<<setw(4)<<(*work).ID;cout<<" | "<<setw(4)<<(*work).sc1.jiben;cout<<" | "<<setw(4)<<(*work).sc1.zhiwu;cout<<" | "<<setw(4)<<(*work).sc1.gangwei;cout<<" | "<<setw(4)<<(*work).sc1.yiliao;cout<<" | "<<setw(4)<<(*work).sc1.gongji;cout<<" |"<<setw(4)<<(*work).sc1.sum;cout<<" |"<<setw(4)<<(*work).sc1.avarage;cout<<" | "<<endl;}work=work->next;}while(work!=NULL);if(flag==0)cout<<"对不起!您要查询的职工不存在"<<endl;cout<<"您想继续查询吗(y/n)"; cin>>c;while(c!='y'&&c!='n'){cout<<"指令错误<请输入y/n!>"<<endl;cout<<"您想继续查询吗(y/n)"; cin>>c;}}while(c=='y');}void search2(worker *head){char c;string ID;do{worker *work=head->next;int flag=0;cout<<"请输入要查找职工的ID";cin>>ID;do{if(work!=NULL&&ID==(*work).ID){flag=1;cout<<"你要查询的学生是"<<work->name<<endl;cout<<" | name | ID |底子工资|职务工资|岗位津贴|医疗保险|公积金|总工资|平均工资|"<<endl;cout<<" | "<<setw(4)<<(*work).name;cout<<" | "<<setw(4)<<(*work).ID;cout<<" | "<<setw(4)<<(*work).sc1.jiben;cout<<" | "<<setw(4)<<(*work).sc1.zhiwu;cout<<" | "<<setw(4)<<(*work).sc1.gangwei;cout<<" | "<<setw(4)<<(*work).sc1.yiliao;cout<<" | "<<setw(4)<<(*work).sc1.gongji;cout<<" | "<<setw(4)<<(*work).sc1.sum;cout<<" | "<<setw(4)<<(*work).sc1.avarage;cout<<" | "<<endl;}work=work->next;}while(work!=NULL);if(flag==0)cout<<"对不起!您要查询的职工不存在"<<endl;cout<<"您想继续查询吗(y/n)";cin>>c;while(c!='y'&&c!='n'){cout<<"指令错误<请输入y/n!>"<<endl;cout<<"您想继续查询吗(y/n)"<<endl;cin>>c;}}while(c=='y');}void xiugai(worker *head){string name;char c;do{bool flag2=0;worker *work=head->next;xinxi sc1;cout<<"请输入你要点窜的职工的姓名:";cin>>name;do{if(name==(*work).name){flag2=1;cout<<"请输入新的底子工资:";cin>>sc1.jiben;cout<<"请输入新的职务工资:";cin>>sc1.zhiwu;cout<<"请输入新的岗位津贴:";cin>>sc1.gangwei;cout<<"请输入新的医疗保险:";cin>>sc1.yiliao;cout<<"请输入新的公积金:";cin>>sc1.gongji;(*work).sc1.jiben=sc1.jiben;(*work).sc1.zhiwu=sc1.zhiwu;(*work).sc1.gangwei=sc1.gangwei;(*work).sc1.sum=(*work).sc1.gangwei+(*work).sc1.gongji+(*work).sc1.jiben+(*work).sc1. yiliao+(*work).sc1.zhiwu;(*work).sc1.avarage=((*work).sc1.gangwei+(*work).sc1.gongji+(*work).sc1.jiben+(*work). sc1.yiliao+(*work).sc1.zhiwu)/5;cout<<" | name | ID |底子工资|职务工资|岗位津贴|医疗保险|公积金|总工资|平均工资|"<<endl;cout<<" | "<<setw(4)<<(*work).name;cout<<" | "<<setw(4)<<(*work).ID;cout<<" | "<<setw(4)<<(*work).sc1.jiben;cout<<" | "<<setw(4)<<(*work).sc1.zhiwu;cout<<" | "<<setw(4)<<(*work).sc1.gangwei;cout<<" | "<<setw(4)<<(*work).sc1.yiliao;cout<<" | "<<setw(4)<<(*work).sc1.gongji;cout<<" | "<<setw(4)<<(*work).sc1.sum;cout<<" | "<<setw(4)<<(*work).sc1.avarage;cout<<" | "<<endl;cout<<"数据点窜成功......";break;}work=work->next;}while(work!=NULL);if(flag2==0){cout<<"对不起!您要点窜的职工不存在!请查抄从头输入"<<endl; }cout<<"想继续点窜吗(y/n)";cin>>c;if(c!='y'&&c!='n'){cout<<"指令错误!请从头输入<y/n>";cin>>c;}}while(c=='y');}void shanchu(worker *head){char c;string no;do{int flag=0;cout<<"请输入要删除的职工ID";cin>>no;worker *p,*q;q=head;while(q->next!=NULL&&q->next->ID!=no)q=q->next;if(q->next!=NULL){flag=1;p=q->next;q->next=q->next->next;amount--;free(p);cout<<"......成功删除! ";}if(flag==0)cout<<"对不起!您要删除的职工不存在"<<endl;cout<<"您想继续删除吗(y/n)";cin>>c;while(c!='y'&&c!='n'){cout<<"指令错误<请输入y/n!>"<<endl;cout<<"您想继续删除吗(y/n)";cin>>c;}}while(c=='y');}void tongji(worker *head){char c;string name;do{worker *work=head->next;bool flag=0;cout<<"----总工资和平均工资的计算------"<<endl;cout<<"请输入要统计职工的姓名";cin>>name;do{if(work!=NULL&&name==(*work).name){flag=1;cout<<" | name | ID |底子工资|职务工资|岗位津贴|医疗保险|公积金|总工资|平均工资|"<<endl;cout<<" | "<<setw(4)<<(*work).name;cout<<" | "<<setw(4)<<(*work).ID;cout<<" | "<<setw(4)<<(*work).sc1.jiben;cout<<" | "<<setw(4)<<(*work).sc1.zhiwu;cout<<" | "<<setw(4)<<(*work).sc1.gangwei;cout<<" | "<<setw(4)<<(*work).sc1.yiliao;cout<<" | "<<setw(4)<<(*work).sc1.gongji;cout<<" | "<<setw(4)<<(*work).sc1.sum;cout<<" | "<<setw(4)<<(*work).sc1.avarage;cout<<" | "<<endl;cout<<"超过2000的百分比:"<<endl;cout<<(ab*100)/amount<<"%"<<endl;cout<<"小于2000,大于等于1500"<<endl;cout<<(cd*100)/amount<<"%"<<endl;cout<<"小于1500,大于等于1000"<<endl;cout<<(ef*100)/amount<<"%"<<endl;}work=work->next;}while(work!=NULL);if(flag==0)cout<<"对不起!您要查询的职工不存在"<<endl;cout<<"您想继续查询吗(y/n)"; cin>>c;while(c!='y'&&c!='n'){cout<<"指令错误<请输入y/n!>"<<endl;cout<<"您想继续查询吗(y/n)"; cin>>c;}} while(c=='y');}void tianjia(worker *head){char c;int j=0;worker *p=head;file[j]=new ofstream("D:\\职工办理系统\\职工信息.txt",ios::app);do{worker *work=new worker;cout<<"请输入姓名:"<<setw(10);cin>>(*work).name;cout<<"请输入ID:"<<setw(10);cin>>(*work).ID;cout<<"请输入底子工资:"<<setw(2);cin>>(*work).sc1.jiben;cout<<"请输入职务工资:"<<setw(2);cin>>(*work).sc1.zhiwu;cout<<"请输入岗位津贴:"<<setw(2);cin>>(*work).sc1.gangwei;cout<<"请输入医疗保险:"<<setw(2);cin>>(*work).sc1.yiliao;cout<<"请输入公积金:"<<setw(2);cin>>(*work).sc1.gongji;(*work).sc1.sum=(*work).sc1.gangwei+(*work).sc1.gongji+(*work).sc1.yiliao+(*work).sc1.zhiwu+(*work).sc1.jiben;(*work).sc1.avarage=((*work).sc1.gangwei+(*work).sc1.gongji+(*work).sc1.yiliao+(*work).sc1. zhiwu+(*work).sc1.jiben)/5;(*work).sc1.sum1=(*work).sc1.gangwei+(*work).sc1.zhiwu+(*work).sc1.jiben;if((*work).sc1.sum1>=2000) ab++;if((*work).sc1.sum1>=1500&&(*work).sc1.sum1<2000) cd++;if((*work).sc1.sum1>=1000&&(*work).sc1.sum1<1500) ef++;work->next=p->next;p->next=work;amount++;cout<<"数据添加成功,想继续添加吗(y/n)"; cin>>c;p=p->next;while(c!='y'&&c!='n'){cout<<"指令错误<请输入y/n!>"<<endl;cout<<"数据添加成功,想继续添加吗(y/n)";cin>>c;}}while(c=='y');j++;cout<<"输入了"<<amount<<"个职工的信息."<<endl;}。

c语言课程设计职工工资管理系统源代码

c语言课程设计职工工资管理系统源代码

绝对可以完美运行,下面有运行图片#include<stdio.h> //调用库函数#include<string.h> //字符串处理#include<conio.h> //控制台输入输出#include<stdlib.h> //定义杂项函数及内存分配函数#define N 2 //宏定义以3代替N/******************************************************************************函数声明*******************************************************************************/ void enter();int menu();void input();void output();void search();void search_employeeid();void search_name();void edit();void array();void array_basesalary();void array_postwage();void array_totalwage();void statistics();void save();void load();/******************************************************************************职工类型定义*******************************************************************************/ struct employee{char employeeid[10];char name[10];char sex[10];int age;float basesalary;float postwage;float totalwage;};/******************************************************************************职工变量定义******************************************************************************/ struct employee emp[N];struct employee replace;struct employee *p=emp;/*****************************************************************************系统主函数******************************************************************************/ void main(){int c;while(1){printf(" \n\n\n\n");printf(" 欢迎进入职工工资管理系统\n\n\n");printf(" 1 进入管理系统\n\n");printf(" 0 退出\n\n");printf(" \n\n\n\n");printf(" 请输入你选择:\n");scanf("%d",&c);switch(c){case 1:enter();break;case 0:printf(" 谢谢使用!\n");exit(0);}}}/***************************************************************************** 功能:登陆函数,进行密码验证*****************************************************************************/ void enter(){char q;char key[10],password[10]="china";int k=1,i;printf(" 请输入密码:\n");for(i=0;i<5;i++){q=getch();key[i]=q;printf("*");}while(k<=3){if(strncmp(key,password,5)==0){while(1){int a;//system("cls");a=menu();switch(a){case 1:input();break;case 2:output();break;case 3:search();break;case 4:edit();break;case 5:array();break;case 6:load();statistics();break;case 0:printf("\n\n 谢谢使用!\n\n\n\n");save();exit(0);}}}else{k++;printf(" 输入密码错误!请再次输入:");for(i=0;i<5;i++){q=getch();key[i]=q;printf("*");}if(k>2){if(strncmp(password,key,5)==0)continue;else{printf(" 输入密码错误三次,系统将自动退出!\n");exit(0);}}}}}/************************************************************************功能: 主菜单函数参数:a类型:int说明: 变量返回值: a************************************************************************/int menu(){int a ;printf("\n\n");printf("|*****************欢迎进入职工工资管理系统************************|\n");printf("| |\n");printf("| |\n");printf("| 1 职工信息输入|\n");printf("| |\n");printf("| 2 职工信息输出|\n");printf("| |\n");printf("| 3 职工信息查询|\n");printf("| |\n");printf("| 4 职工信息修改|\n");printf("| |\n");printf("| 5 工资排序|\n");printf("| |\n");printf("| 6 工资统计|\n");printf("| |\n");printf("| 0 退出|\n");printf("| |\n");printf("| |\n");printf("|*****************************************************************|\n");printf("\n\n");printf(" 请输入你所选择的选项:");scanf("%d",&a);while(a>6||a<0){printf(" error!\n");printf(" 请重新输入你所选择的选项:");scanf("%d",&a);}return a;}/********************************************************************************* ***功能:职工信息输入********************************************************************************** ***/void input(){int c;p=emp;printf(" 进入职工信息输入模块\n\n\n");for(c=0;c<N;c++,p++){p[c].totalwage=p[c].basesalary+p[c].postwage;printf(" 请输入第%d个职工信息:\n\n",c+1);printf(" 请输入职工号:\n");scanf("%s",p->employeeid);if(strcmp(p->employeeid,"0")!=0){printf(" 请输入职工姓名:\n");scanf("%s",p->name);printf(" 请输入职工性别: \n");scanf("%s",&p->sex);printf(" 请输入职工年龄: \n");scanf("%d",&p->age);printf(" 请输入职工基本工资:\n");scanf("%f",&p->basesalary);printf(" 请输入职工岗位工资:\n");scanf("%f",&p->postwage);printf(" 职工信息输入完成!\n\n");}elsereturn;}save();}/******************************************************************************* 功能:职工信息输出********************************************************************************/ void output(){int j;load();p=emp;printf(" 进入职工信息输出模块\n\n\n");printf("-------------------------------------------------------------------------------\n");printf("| 职工号|姓名|性别|年龄|基本工资|岗位工资|总工资|\n");printf("-------------------------------------------------------------------------------\n");for(j=0;j<N;j++){p[j].totalwage=p[j].postwage+p[j].basesalary;printf("|%10s|%9s|%7s| %5d| %10.2f| %10.2f| %10.2f|\n",p[j].employeeid,p[j].name,p [j].sex,p[j].age,p[j].basesalary,p[j].postwage,p[j].totalwage);printf("-------------------------------------------------------------------------------\n");}printf("\n\n 职工信息输出完成!\n\n");getchar();}/******************************************************************************功能:职工信息查询******************************************************************************/ void search(){int j;while(1){printf("*********************职工信息查询*********************\n\n\n");printf(" 1 按职工号查询\n");printf(" 2 按职工姓名查询\n");printf(" 0 退出该项操作\n");printf("\n\n");while(1){printf(" 请输入你的选择\n");scanf("%d",&j);if(j>=0&&j<=2){switch(j){case 1:search_employeeid();break;case 2:search_name();break;case 0:return;}}else{printf(" 输入错误!\n\n");printf(" 请再次输入你的选择: \n\n");}}}}/******************************************************************************* 功能:按职工号查询函数*******************************************************************************/ void search_employeeid(){char employeeid[10];int k,j;p=emp;printf("*********************按职工号查询职工信息*****************************\n\n\n\n");printf(" 请输入要查询职工的职工号:\n\n");scanf("%s",employeeid);for(k=0;k<N;k++){if(strcmp(employeeid,p->employeeid)==0){j=k;p[j].totalwage=p[j].postwage+p[j].basesalary;printf("-------------------------------------------------------------------------------\n");printf("| 职工号|姓名|性别|年龄|基本工资|岗位工资|总工资|\n");printf("|%10s|%9s|%7s| %5d| %10.2f| %10.2f| %10.2f|\n",p[j].employeeid,p[j].name,p [j].sex,p[j].age,p[j].basesalary,p[j].postwage,p[j].totalwage);printf("-------------------------------------------------------------------------------\n");break;}else{printf(" not found\n");return;}}}/*****************************************************************************功能:按职工姓名查询函数*****************************************************************************/ void search_name(){char name[10];int flog=0;int f,j;p=emp;printf("******************************按职工姓名查询职工信息***********************\n\n\n");printf(" 请输入要查询职工的姓名:\n\n");scanf("%s",name);for(f=0;f<N;f++,p++){if(strcmp(name,p->name)==0){j=f;p[j].totalwage=p[j].postwage+p[j].basesalary;printf("-------------------------------------------------------------------------------\n");printf("| 职工号|姓名|性别|年龄|基本工资|岗位工资|总工资|\n");printf("|%10s|%9s|%7s| %5d| %10.2f| %10.2f| %10.2f|\n",p[j].employeeid,p[j].name,p [j].sex,p[j].age,p[j].basesalary,p[j].postwage,p[j].totalwage);printf("-------------------------------------------------------------------------------\n");break;}else{printf(" not found \n\n");return;}}getchar();}/*******************************************************************************功能:职工信息修改函数*******************************************************************************/ void edit(){char e[10];int g=0,j;char flog;p=emp;printf(" 请输入你要修改职工的职工号:\n");scanf("%s",e);for(g=0;g<N;g++){// if(*e==p[g].employeeid)if(strcmp(e,p->employeeid)==0){j=g;p[j].totalwage=p[j].postwage+p[j].basesalary;printf("-------------------------------------------------------------------------------\n");printf("| 职工号|姓名|性别|年龄|基本工资|岗位工资|总工资|\n");printf("|%10s|%9s|%7s| %5d| %10.2f| %10.2f| %10.2f|\n",p[j].employeeid,p[j].name,p[j].sex ,p[j].age,p[j].basesalary,p[j].postwage,p[j].totalwage);printf("-------------------------------------------------------------------------------\n");printf(" 是否要修改该职工信息?y(是)or n(否)?\n\n");getchar();scanf("%c",&flog);if(flog == 'y'){printf(" 请输入新姓名:\n");scanf("%s",p->name);printf(" 请输入性别:\n");scanf("%s",&p->sex);printf(" 请输入年龄:\n");scanf("%d",&p->age);printf(" 请输入基本工资:\n");scanf("%f",&p->basesalary);printf(" 请输入岗位工资:\n");scanf("%f",&p->postwage);printf(" 修改职工信息成功!\n\n");}if(flog == 'n'){printf(" 退出该项操作!\n\n");return;}save();}if(g==N){printf(" not found \n\n\n");return;}}}/************************************************************************ 功能:职工工资排列函数************************************************************************/ void array(){int j;while(1){printf("*************************工资排序*********************\n\n");printf(" 1 按基本工资排序\n\n");printf(" 2 按岗位工资排序\n\n");printf(" 3 按总工资排列\n\n");printf(" 0 退出\n\n");printf("\n\n\n");while(1){printf(" 请输入你的选择:\n\n");scanf("%d",&j);if(j>=0&&j<=3){switch(j){case 1:array_basesalary();break;case 2:array_postwage();break;case 3:array_totalwage();break;case 0:return;}}else{printf(" 输入错误!\n\n\n");printf(" 请再次输入你的选择:\n\n");}}}}/**************************************************************************功能:按基本工资排列(选择法)***************************************************************************/void array_basesalary(){int i,j,k;p=emp;for(i=0;i<N-1;i++){k=i;for(j=i+1;j<N;j++){if(p[k].basesalary<p[j].basesalary)k=j;}if(k!=i){replace=emp[k];emp[k]=emp[i];emp[i]=replace;}}for(j=0;j<N;j++){p[j].totalwage=p[j].postwage+p[j].basesalary;printf("-------------------------------------------------------------------------------\n");printf("| 职工号|姓名|性别|年龄|基本工资|岗位工资|总工资|\n");printf("|%10s|%9s|%7s| %5d| %10.2f| %10.2f| %10.2f|\n",p[j].employeeid,p[j].name,p [j].sex,p[j].age,p[j].basesalary,p[j].postwage,p[j].totalwage);}printf("-------------------------------------------------------------------------------\n");}/************************************************************************功能:按岗位工资排列(冒泡法)*************************************************************************/void array_postwage(){int i,j;p=emp;for(i=0;i<N;i++){for(j=0;j<N-i;j++){if(p[j].postwage<p[j+1].postwage){replace=emp[j];emp[j]=emp[j+1];emp[j+1]=replace;}}}for(j=0;j<N;j++){p[j].totalwage=p[j].postwage+p[j].basesalary;printf("------------------------------------------------------------------------------\n");printf("| 职工号|姓名|性别|年龄|基本工资|岗位工资|总工资|\n");printf("|%10s|%9s|%7s| %5d| %10.2f| %10.2f| %10.2f|\n",p[j].employeeid,p[j].name,p [j].sex,p[j].age,p[j].basesalary,p[j].postwage,p[j].totalwage);}printf("-------------------------------------------------------------------------------\n");}/************************************************************************功能:按总工资排列(插入法)************************************************************************/void array_totalwage(){int i,j;p=emp;for(i=1;i<N;i++){replace=emp[i];for(j=i-1;j>=0&&p[i].totalwage>p[i].totalwage;j--){emp[j+1]=emp[j];emp[j+1]=replace;}}for(j=N-1;j>=0;j--){p[j].totalwage=p[j].postwage+p[j].basesalary;printf("-------------------------------------------------------------------------------\n");printf("| 职工号|姓名|性别| 年龄|基本工资|岗位工资|总工资|\n");printf("|%10s|%9s|%7s| %5d| %10.2f| %10.2f| %10.2f|\n",p[j].employeeid,p[j].name,p [j].sex,p[j].age,p[j].basesalary,p[j].postwage,p[j].totalwage);}printf("-------------------------------------------------------------------------------\n");}/*************************************************************************功能:工资统计函数**************************************************************************/void statistics(){int z,a=0,b=0,c=0;p=emp;for(z=0;z<N;z++){if(p[z].totalwage>3000){a++;continue;}if(p[z].totalwage>=2000&&p[z].totalwage<=3000){b++;continue;}if(p[z].totalwage<=2000&&p[z].totalwage>0){c++;continue;}}printf(" 总工资在3000元以上的职工人数有:%d\n\n",a);printf(" 总工资在2000元至3000元的职工人数有:%d\n\n",b);printf(" 总工资在2000元以下的职工人数有:%d\n\n",c);getchar();}/*************************************************************************** 功能:导出函数***************************************************************************/ void save(){int k;FILE *fp;p=emp;if((fp=fopen("emp_list","wb"))==NULL){printf(" Create file error!\n");return;}for(k=0;k<N;k++,p++){if(fwrite(p,sizeof(struct employee),1,fp)!=1){printf(" file save error!\n\n");break;}elsecontinue;}getchar();fclose(fp);}/***********************************************************************功能:导入函数***********************************************************************/ void load(){int l;FILE *fp;p=emp;if((fp=fopen("emp_list","rb"))==NULL){printf(" Create file error!\n");exit(0);}for(l=0;l<N;l++,p++){if(fread(p,sizeof(struct employee),1,fp)!=1){printf(" file read error!\n\n");break;}elsecontinue;}getchar();fclose(fp);}下面是实验结果。

员工工资管理系统源代码

员工工资管理系统源代码

#include<stdio.h>#include<string.h> typedefstruct {int basic;// 基本工资int position;// 岗位工资int subsidy;// 津贴intwages;// 奖金int sum;// 总工资}money;typedef struct{char num[20];// 职工号char name[20];// 姓名int age;// 年龄charsex[20];// 性别moneysalary;// 工资}employee;int Print_jinru();// 账号密码输入void Fscan_information();// “职工信息.txt ”文件写入void Print_staff();// 全体员工void Print_empl1(char x[51]);// 按职工号查询void Print_empl2(char s[51]);// 按姓名查询void Print_MainInterface();// 主界面void Print_Interface_1();// 职工信息录入界面void Print_Interface_2();// 职工信息查询界面void Print_Interface_3();// 职工工资排序界面void Print_Interface_4();// 职工总工资void Print_Interface_5();// 文件读出void qsort(int l,int r);// 快速排序voidPrint_delete(int t);// 删除职工信息void Print_Interface_2_1(int t);// 职工信息修改界面int fyanzheng(char s1[],char s2[]);// 密码验证函数employee st[500];// 记录职工信息的函数int n;// 职工总数void main(){int x;employee em;printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@\n");printf("@@@@ 欢迎使用员工工资管理系统@@@@\n");printf("@@@@ 制作人:刘爽@@@@\n");printf("@@@@ 在使用中产生的任何问题,欢迎进行批评指正@@@@\n");printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@\n");printf("\n");printf("\n");printf("\n");if (Print_jinru()){Fscan_information();Print_MainInterface();}else return;}void Fscan_information(){FILE *fp;int i;if ((fp=fopen(" 职工信息.txt","r"))==NULL){printf("cannot open this file\n");return ;}fscanf(fp,"%d",&n);for (i=1;i<=n;i++){fscanf(fp,"%s%s%d%s%d%d%d",st[i].num,st[i].name,&st[i].age,st[i].sex,&st[i].salary.basic,&s t[i].salary.subsidy,&st[i].salary.wages);st[i].salary.sum=st[i].salary.basic+st[i].salary.subsidy+st[i].salary.wages;}fclose(fp);}int fyanzheng(char s1[],char s2[]){FILE *fp1,*fp2;char str1[40]="",str2[40]="",st;int t;if ((fp1=fopen(" 账号验证.in","r"))==NULL){printf("cannot open this file\n");return 0;} t=0;st=fgetc(fp1);while (st!='#'){str1[t]=st;t++;st=fgetc(fp1);}if ((fp2=fopen(" 密码验证.in","r"))==NULL){printf("cannot open this file\n");return 0;}t=0;st=fgetc(fp2);while (st!='#'){str2[t]=st;t++;st=fgetc(fp2);}fclose(fp1);fclose(fp2);if ((strcmp(str1,s1)==0)&&(strcmp(str2,s2)==0)) return 1;elsereturn 0;}int Print_jinru(){int f,d;char x[20],y[20];f=0;d=0;while(1){printf(" 请输入账号:"); scanf("%s",x); getchar();printf(" 请输入密码:"); scanf("%s",y); getchar();f=fyanzheng(x,y);if (d>3)printf(" 错误次数太多,退出系统 \n");return 0;}if (f>0) break;else{printf(" 账号或密码输入错误,请重新输入 \n"); d++;}}printf("\n");printf(" 欢迎进入员工工资管理系统!!!\n");return 1;}else void Print_MainInterface(){int x;printf("\n");printf(" *************************printf("\n");printf("1. 职工信息录入 \n");printf("2. 职工信息查询 \n");printf("3. 职工工资排序 \n");printf("4. 统计职工总工资 \n");printf("5. 保存到文件 \n");printf("6. 退出职工工资系统 \n");printf(" 请选择所需操作 :");scanf("%d",&x);if (x==1)Print_Interface_1();elseif (x==2)Print_Interface_2();elseif (x==3)Print_Interface_3();elseif (x==4)Print_Interface_4();elseif (x==5)Print_Interface_5();华丽的分割线 *********************** **\n");if (x==6){printf(" ******printf("*printf("*printf(" ****** printf(" printf(" printf(" ****** ******** ************ ********************** ******\n");*\n");*\n");*\n");*\n");*\n");\n");printf("233333333333333333333333333333333333333333333333333333\n"); return;} else{printf(" 输入命令错误,返回主菜单 (再乱输入我找人打你啊 )\n");Print_MainInterface(); }}void Print_Interface_1(){n++;if (n>500){printf(" 超出职工最大数 \n");Print_MainInterface();} printf("\n");printf(" ************************* printf("\n");printf(" 新建职工号 :");scanf("%s",st[n].num);printf(" 姓名 :"); scanf("%s",st[n].name);printf(" 年龄 :"); scanf("%d",&st[n].age);printf(" 性别 :"); scanf("%s",st[n].sex);printf(" 基本工资 :"); scanf("%d",&st[n].salary.basic);printf(" 津贴 :"); scanf("%d",&st[n].salary.subsidy);printf(" 奖金 :"); scanf("%d",&st[n].salary.wages);st[n].salary.sum=st[n].salary.basic+st[n].salary.subsidy+st[n].salary.wages; // 妖精的分割线 *************************\n");printf(" 职工信息已成功录入\n");Print_MainInterface();}void Print_Interface_2(){int x;char s[50],y[50];printf("\n");printf(" ************************* 逗比的分割线*********************** **\n");printf("\n");printf("1. 查询所有职工\n");printf("2. 按职工号查询\n"); printf("3. 按职工姓名查询\n");printf("4. 返回主菜单\n"); printf(" 请选择查找方式:\n");scanf("%d",&x);if (x==1)Print_staff();elseif (x==2){printf(" 请输入职工工号:"); scanf("%s",y);Print_empl1(y);}elseif (x==3){printf(" 请输入职工姓名:"); scanf("%s",s);Print_empl2(s);}elseif (x==4)Print_MainInterface();else{printf(" 输入命令错误,返回上一层\n"); Print_Interface_2();}}void Print_Interface_3(){char ch[10];printf("\n");qsort(1,n);printf(" 排序完成!排序后结果请从查询全体职工处查看\n");Print_MainInterface();}void Print_Interface_4(){int i,All=0;char ch[10];printf("\n");for (i=1;i<=n;i++)All=All+st[i].salary.sum;printf(" 所有职工的总工资为:%d\n",All);printf(" 请输入任意字符并敲回车键返回主菜单\n");scanf("%s",&ch);Print_MainInterface();}void Print_Interface_5(){FILE *fp;char ch[10];int i;if ((fp=fopen(" 职工信息.txt","w"))==NULL){printf("cannot open this file\n");return ;}fprintf(fp,"%d\n",n);for (i=1;i<=n;i++)fprintf(fp,"%s %s %d %s %d %d %d\n",st[i].num,st[i].name,st[i].age,st[i].sex,st[i].salary.basic, st[i].salary.subsidy,st[i].salary.wages);fclose(fp);printf("\n");printf(" 已保存到文件\n");printf("\n");printf(" 请输入任意字符返回主菜单\n");scanf("%s",&ch);Print_MainInterface();}void Print_staff(){int i;printf("\n");printf(" ************************* 帅比的分割线*************************" );printf("\n");for (i=1;i<=n;i++){printf(" 职工工号:%s\n",st[i].num);printf(" 姓名:%s\n",st[i].name);printf(" 年龄:%d\n",st[i].age);printf(" 性别:%s\n",st[i].sex);printf(" 基本工资:%d\n",st[i].salary.basic);printf(" 津贴:%d\n",st[i].salary.subsidy);printf(" 奖金:%d\n",st[i].salary.wages);printf(" 总工资:%d\n",st[i].salary.sum); printf("\n");}printf(" 返回上一层\n");Print_Interface_2();}void Print_empl1(char x[]) {int i,t,y,d=0;printf("\n");for (i=1;i<=n;i++)if (strcmp(x,st[i].num)==0) { t=i;d=1;printf(" 职工工号:%s\n",st[i].num);printf(" 姓名:%s\n",st[i].name);printf(" 年龄:%d\n",st[i].age);printf(" 性别:%s\n",st[i].sex);printf(" 基本工资:%d\n",st[i].salary.basic);printf(" 津贴:%d\n",st[i].salary.subsidy); printf(" 奖金:%d\n",st[i].salary.wages);printf(" 总工资:%d\n",st[i].salary.sum); printf("\n");break;}if (d>0){printf(" 如需删除请按2,修改请按1,返回请按0\n"); scanf("%d",&y);if (y==2)Print_delete(t);else if (y==1)Print_Interface_2_1(t);else if (y==0) Print_Interface_2();else{printf(" 输入命令错误,返回上一层(再乱输入我找人打你啊)\n");Print_Interface_2();}}else{printf(" 对不起,查无此人(本系统不包括路人甲乙丙,不要乱输-_-! )\n");printf(" 请重新选择查询方式\n");Print_Interface_2();}}void Print_empl2(char s[]){int i,t,x,y=0;printf("\n");for (i=1;i<=n;i++)if (strcmp(s,st[i].name)==0){t=i;y=1;printf(" 职工工号:%s\n",st[i].num);printf(" 姓名:%s\n",st[i].name);printf(" 年龄:%d\n",st[i].age);printf(" 性别:%s\n",st[i].sex);printf(" 基本工资:%d\n",st[i].salary.basic);printf(" 津贴:%d\n",st[i].salary.subsidy);printf(" 奖金:%d\n",st[i].salary.wages);printf(" 总工资:%d\n",st[i].salary.sum);printf("\n");break;}if (y>0){printf(" 如需删除请按2,修改请按1,返回请按0(再乱输入我找人打你啊)\n");scanf("%d",&x);if (x==2)Print_delete(t);elseif (x==1) Print_Interface_2_1(t);else if (x==0) Print_Interface_2();else{ printf(" 输入命令错误,返回上一层\n"); Print_Interface_2();}}else{printf(" 对不起,查无此人(本系统不包括路人甲乙丙,不要乱输-_-! )\n");printf(" 请重新选择查询方式\n");Print_Interface_2();}}void Print_delete(int t){st[t].salary.sum=0;qsort(1,n);n--;printf(" 已删除该职工并排序,自动返回主菜单\n");Print_MainInterface();}void Print_Interface_2_1(int t){int x;printf("\n");printf(" 请选择以下选项:\n");printf("1. 职工号\n");printf("2. 姓名\n");printf("3. 年龄\n");printf("4. 性别\n");printf("5. 基本工资\n");printf("6. 津贴\n");printf("7. 奖金\n");printf("8. 返回上一层\n");printf("9. 返回主菜单\n");scanf("%d",&x);switch(x){case 1:scanf("%s",st[t].num);break;case 2: scanf("%s",st[t].name);break;case 3: scanf("%d",st[t].age);break;case 4: scanf("%s",st[t].sex);break;case 5: scanf("%s",st[t].salary.basic);break;case 6: scanf("%d",st[t].salary.subsidy);break;case 7: scanf("%d",st[t].salary.wages);break;} st[t].salary.sum=st[t].salary.basic+st[t].salary.subsidy+st[t].salary.wages;if (x<=8)Print_Interface_2();elseif (x==9) Print_MainInterface();}void qsort(int l,int r){int i,j,mid;employee tt;i=l;j=r;mid=st[(l+r)/2].salary.sum;do{while (st[i].salary.sum>mid) i++;while (st[j].salary.sum<mid) j--;if (i<=j){tt=st[i];st[i]=st[j];st[j]=tt;i++;j--;}}while(i<=j);if (i<r) qsort(i,r);if (l<j) qsort(l,j);。

员工工资管理系统源代码

员工工资管理系统源代码

#include<stdio.h>#include<string.h>typedef struct{int basic;//基本工资int position;//岗位工资int subsidy;//津贴int wages;//奖金int sum;//总工资}money;typedef struct{char num[20];//职工号char name[20];//姓名int age;//年龄char sex[20];//性别money salary;//工资}employee;int Print_jinru();//账号密码输入void Fscan_information();//“职工信息.txt”文件写入void Print_staff();//全体员工void Print_empl1(char x[51]);//按职工号查询void Print_empl2(char s[51]);//按姓名查询void Print_MainInterface();//主界面void Print_Interface_1();//职工信息录入界面void Print_Interface_2();//职工信息查询界面void Print_Interface_3();//职工工资排序界面void Print_Interface_4();//职工总工资void Print_Interface_5();//文件读出void qsort(int l,int r);//快速排序void Print_delete(int t);//删除职工信息void Print_Interface_2_1(int t);//职工信息修改界面int fyanzheng(char s1[],char s2[]);//密码验证函数employee st[500];//记录职工信息的函数int n;//职工总数void main(){int x;employee em;printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@\n");printf("@@@@ 欢迎使用员工工资管理系统@@@@\n");printf("@@@@ 制作人:刘爽@@@@\n");printf("@@@@在使用中产生的任何问题,欢迎进行批评指正@@@@\n");printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@\n");printf("\n");printf("\n");printf("\n");if (Print_jinru()){Fscan_information();Print_MainInterface();}else return;}void Fscan_information(){FILE *fp;int i;if ((fp=fopen("职工信息.txt","r"))==NULL){printf("cannot open this file\n");return ;}fscanf(fp,"%d",&n);for (i=1;i<=n;i++){fscanf(fp,"%s%s%d%s%d%d%d",st[i].num,st[i].name,&st[i].age,st[i].sex,&st[i].s alary.basic,&st[i].salary.subsidy,&st[i].salary.wages);st[i].salary.sum=st[i].salary.basic+st[i].salary.subsidy+st[i].salary.wages;}fclose(fp);}int fyanzheng(char s1[],char s2[]){FILE *fp1,*fp2;char str1[40]="",str2[40]="",st;int t;if ((fp1=fopen("账号验证.in","r"))==NULL){printf("cannot open this file\n");return 0;}t=0;st=fgetc(fp1);while (st!='#'){str1[t]=st;t++;st=fgetc(fp1);}if ((fp2=fopen("密码验证.in","r"))==NULL){printf("cannot open this file\n");return 0;}t=0;st=fgetc(fp2);while (st!='#'){str2[t]=st;t++;st=fgetc(fp2);}fclose(fp1);fclose(fp2);if ((strcmp(str1,s1)==0)&&(strcmp(str2,s2)==0)) return 1;elsereturn 0;}int Print_jinru(){int f,d;char x[20],y[20];f=0;d=0;while(1){printf("请输入账号:");scanf("%s",x);getchar();printf("请输入密码:");scanf("%s",y);getchar();f=fyanzheng(x,y);if (d>3){printf("错误次数太多,退出系统\n");return 0;}if (f>0) break;else{printf("账号或密码输入错误,请重新输入\n");d++;}}printf("\n");printf("欢迎进入员工工资管理系统!!!\n");return 1;}void Print_MainInterface(){int x;printf("\n");printf("*************************华丽的分割线*************************\n");printf("\n");printf("1.职工信息录入\n");printf("2.职工信息查询\n");printf("3.职工工资排序\n");printf("4.统计职工总工资\n");printf("5.保存到文件\n");printf("6.退出职工工资系统\n");printf("请选择所需操作:");scanf("%d",&x);if (x==1)Print_Interface_1();elseif (x==2)Print_Interface_2();elseif (x==3)Print_Interface_3();elseif (x==4)Print_Interface_4();elseif (x==5)Print_Interface_5();elseif (x==6){printf(" ****** **** **** * * ***** * *\n");printf("* * * * * * * * * * *\n");printf("* * * * * * * * * * *\n");printf(" ****** ******** ******** ** * * * *\n");printf(" * * * ** * * * *\n");printf(" * * * ** * * * *\n");printf(" ****** **** **** ** ***** ***** \n");//printf("233333333333333333333333333333333333333333333333333333\n");return;}else{printf("输入命令错误,返回主菜单(再乱输入我找人打你啊)\n");Print_MainInterface();}}void Print_Interface_1(){n++;if (n>500){printf("超出职工最大数\n");Print_MainInterface();}printf("\n");printf("*************************妖精的分割线*************************\n");printf("\n");printf("新建职工号:");scanf("%s",st[n].num);printf("姓名:");scanf("%s",st[n].name);printf("年龄:");scanf("%d",&st[n].age);printf("性别:");scanf("%s",st[n].sex);printf("基本工资:");scanf("%d",&st[n].salary.basic);printf("津贴:");scanf("%d",&st[n].salary.subsidy);printf("奖金:");scanf("%d",&st[n].salary.wages);st[n].salary.sum=st[n].salary.basic+st[n].salary.subsidy+st[n].salary.wages;printf("职工信息已成功录入\n");Print_MainInterface();}void Print_Interface_2(){int x;char s[50],y[50];printf("\n");printf("*************************逗比的分割线*************************\n");printf("\n");printf("1.查询所有职工\n");printf("2.按职工号查询\n");printf("3.按职工姓名查询\n");printf("4.返回主菜单\n");printf("请选择查找方式:\n");scanf("%d",&x);if (x==1)Print_staff();elseif (x==2){printf("请输入职工工号:");scanf("%s",y);Print_empl1(y);}elseif (x==3){printf("请输入职工姓名:");scanf("%s",s);Print_empl2(s);}elseif (x==4)Print_MainInterface();else{printf("输入命令错误,返回上一层\n");Print_Interface_2();}}void Print_Interface_3(){char ch[10];printf("\n");qsort(1,n);printf("排序完成!排序后结果请从查询全体职工处查看\n");Print_MainInterface();}void Print_Interface_4(){int i,All=0;char ch[10];printf("\n");for (i=1;i<=n;i++)All=All+st[i].salary.sum;printf("所有职工的总工资为:%d\n",All);printf("请输入任意字符并敲回车键返回主菜单\n");scanf("%s",&ch);Print_MainInterface();}void Print_Interface_5(){FILE *fp;char ch[10];int i;if ((fp=fopen("职工信息.txt","w"))==NULL){printf("cannot open this file\n");return ;}fprintf(fp,"%d\n",n);for (i=1;i<=n;i++)fprintf(fp,"%s %s %d %s %d %d %d\n",st[i].num,st[i].name,st[i].age,st[i].sex,st[i] .salary.basic,st[i].salary.subsidy,st[i].salary.wages);fclose(fp);printf("\n");printf("已保存到文件\n");printf("\n");printf("请输入任意字符返回主菜单\n");scanf("%s",&ch);Print_MainInterface();}void Print_staff(){int i;printf("\n");printf("*************************帅比的分割线*************************");printf("\n");for (i=1;i<=n;i++){printf("职工工号:%s\n",st[i].num);printf("姓名:%s\n",st[i].name);printf("年龄:%d\n",st[i].age);printf("性别:%s\n",st[i].sex);printf("基本工资:%d\n",st[i].salary.basic);printf("津贴:%d\n",st[i].salary.subsidy);printf("奖金:%d\n",st[i].salary.wages);printf("总工资:%d\n",st[i].salary.sum);printf("\n");}printf("返回上一层\n");Print_Interface_2();}void Print_empl1(char x[]){int i,t,y,d=0;printf("\n");for (i=1;i<=n;i++)if (strcmp(x,st[i].num)==0){t=i;d=1;printf("职工工号:%s\n",st[i].num);printf("姓名:%s\n",st[i].name);printf("年龄:%d\n",st[i].age);printf("性别:%s\n",st[i].sex);printf("基本工资:%d\n",st[i].salary.basic);printf("津贴:%d\n",st[i].salary.subsidy);printf("奖金:%d\n",st[i].salary.wages);printf("总工资:%d\n",st[i].salary.sum);printf("\n");break;}if (d>0){printf("如需删除请按2,修改请按1,返回请按0\n");scanf("%d",&y);if (y==2)Print_delete(t);elseif (y==1)Print_Interface_2_1(t);elseif (y==0)Print_Interface_2();else{printf("输入命令错误,返回上一层(再乱输入我找人打你啊)\n");Print_Interface_2();}}else{printf("对不起,查无此人(本系统不包括路人甲乙丙,不要乱输-_-!)\n");printf("请重新选择查询方式\n");Print_Interface_2();}}void Print_empl2(char s[]){int i,t,x,y=0;printf("\n");for (i=1;i<=n;i++)if (strcmp(s,st[i].name)==0){t=i;y=1;printf("职工工号:%s\n",st[i].num);printf("姓名:%s\n",st[i].name);printf("年龄:%d\n",st[i].age);printf("性别:%s\n",st[i].sex);printf("基本工资:%d\n",st[i].salary.basic);printf("津贴:%d\n",st[i].salary.subsidy);printf("奖金:%d\n",st[i].salary.wages);printf("总工资:%d\n",st[i].salary.sum);printf("\n");break;}if (y>0){printf("如需删除请按2,修改请按1,返回请按0(再乱输入我找人打你啊)\n");scanf("%d",&x);if (x==2)Print_delete(t);elseif (x==1)Print_Interface_2_1(t);elseif (x==0)Print_Interface_2();else{printf("输入命令错误,返回上一层\n");Print_Interface_2();}}else{printf("对不起,查无此人(本系统不包括路人甲乙丙,不要乱输-_-!)\n");printf("请重新选择查询方式\n");Print_Interface_2();}}void Print_delete(int t){st[t].salary.sum=0;qsort(1,n);n--;printf("已删除该职工并排序,自动返回主菜单\n");Print_MainInterface();}void Print_Interface_2_1(int t){int x;printf("\n");printf("请选择以下选项:\n");printf("1.职工号\n");printf("2.姓名\n");printf("3.年龄\n");printf("4.性别\n");printf("5.基本工资\n");printf("6.津贴\n");printf("7.奖金\n");printf("8.返回上一层\n");printf("9.返回主菜单\n");scanf("%d",&x);switch(x){case 1:scanf("%s",st[t].num);break;case 2:scanf("%s",st[t].name);break;case 3:scanf("%d",st[t].age);break;case 4:scanf("%s",st[t].sex);break;case 5:scanf("%s",st[t].salary.basic);break;case 6:scanf("%d",st[t].salary.subsidy);break;case 7:scanf("%d",st[t].salary.wages);break;}st[t].salary.sum=st[t].salary.basic+st[t].salary.subsidy+st[t].salary.wages;if (x<=8)Print_Interface_2();elseif (x==9)Print_MainInterface();}void qsort(int l,int r){int i,j,mid;employee tt;i=l;j=r;mid=st[(l+r)/2].salary.sum;do{while (st[i].salary.sum>mid) i++;while (st[j].salary.sum<mid) j--;if (i<=j){tt=st[i];st[i]=st[j];st[j]=tt;i++;j--;}}while(i<=j);if (i<r) qsort(i,r);if (l<j) qsort(l,j);。

员工工资管理系统源代码

员工工资管理系统源代码

#include<stdio.h>#include<string.h>typedef struct{int basic;//基本工资int position;//岗位工资int subsidy;//津贴int wages;//奖金int sum;//总工资}money;typedef struct{char num[20];//职工号char name[20];//姓名int age;//年龄char sex[20];//性别money salary;//工资}employee;int Print_jinru();//账号密码输入void Fscan_information();//“职工信息.txt”文献写入void Print_staff();//全体员工void Print_empl1(char x[51]);//按职工号查询void Print_empl2(char s[51]);//按姓名查询void Print_MainInterface();//主界面void Print_Interface_1();//职工信息录入界面void Print_Interface_2();//职工信息查询界面void Print_Interface_3();//职工工资排序界面void Print_Interface_4();//职工总工资void Print_Interface_5();//文献读出void qsort(int l,int r);//快速排序void Print_delete(int t);//删除职工信息void Print_Interface_2_1(int t);//职工信息修改界面int fyanzheng(char s1[],char s2[]);//密码验证函数employee st[500];//记录职工信息的函数int n;//职工总数void main(){int x;employee em;printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@\n");printf("@@@@ 欢迎使用员工工资管理系统@@@@\n");printf("@@@@ 制作人:刘爽@@@@\n");printf("@@@@在使用中产生的任何问题, 欢迎进行批评指正@@@@\n");printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");printf("\n");printf("\n");printf("\n");if (Print_jinru()){Fscan_information();Print_MainInterface();}else return;}void Fscan_information(){FILE *fp;int i;if ((fp=fopen("职工信息.txt","r"))==NULL){printf("cannot open this file\n");return ;}fscanf(fp,"%d",&n);for (i=1;i<=n;i++){fscanf(fp,"%s%s%d%s%d%d%d",st[i].num,st[i].name,&st[i].age,st[i].sex,&st[i].salary.basic,&st[i].salary.subsidy,&st[i].salary.wages);st[i].salary.sum=st[i].salary.basic+st[i].salary.subsidy+st[i].salary.wages;}fclose(fp);}int fyanzheng(char s1[],char s2[]){FILE *fp1,*fp2;char str1[40]="",str2[40]="",st;int t;if ((fp1=fopen("账号验证.in","r"))==NULL){printf("cannot open this file\n");return 0;}t=0;st=fgetc(fp1);while (st!='#'){str1[t]=st;t++;st=fgetc(fp1);}if ((fp2=fopen("密码验证.in","r"))==NULL){printf("cannot open this file\n");return 0;}t=0;st=fgetc(fp2);while (st!='#'){str2[t]=st;t++;st=fgetc(fp2);}fclose(fp1);fclose(fp2);if ((strcmp(str1,s1)==0)&&(strcmp(str2,s2)==0)) return 1;elsereturn 0;}int Print_jinru(){int f,d;char x[20],y[20];f=0;d=0;while(1){printf("请输入账号:");scanf("%s",x);getchar();printf("请输入密码:");scanf("%s",y);getchar();f=fyanzheng(x,y);if (d>3){printf("错误次数太多, 退出系统\n");return 0;}if (f>0) break;else{printf("账号或密码输入错误, 请重新输入\n");d++;}}printf("\n");printf("欢迎进入员工工资管理系统\n");return 1;}void Print_MainInterface(){int x;printf("\n");printf("*************************华丽的分割线*************************\n");printf("\n");printf("1.职工信息录入\n");printf("2.职工信息查询\n");printf("3.职工工资排序\n");printf("4.记录职工总工资\n");printf("5.保存到文献\n");printf("6.退出职工工资系统\n");printf("请选择所需操作:");scanf("%d",&x);if (x==1)Print_Interface_1();elseif (x==2)Print_Interface_2();elseif (x==3)Print_Interface_3();elseif (x==4)Print_Interface_4();elseif (x==5)Print_Interface_5();elseif (x==6){printf(" ****** **** **** * * ***** * *\n");printf("* * * * * * * * * * *\n");printf("* * * * * * * * * * *\n");printf(" ****** ******** ******** ** * * * *\n");printf(" * * * ** * * * *\n");printf(" * * * ** * * * *\n");printf(" ****** **** **** ** ***** ***** \n");// printf("333333\n");return;}else{printf("输入命令错误, 返回主菜单(再乱输入我找人打你啊)\n");Print_MainInterface();}}void Print_Interface_1(){n++;if (n>500){printf("超过职工最大数\n");Print_MainInterface();}printf("\n");printf("*************************妖精的分割线*************************\n"); printf("\n");printf("新建职工号:");scanf("%s",st[n].num);printf("姓名:");scanf("%s",st[n].name);printf("年龄:");scanf("%d",&st[n].age);printf("性别:");scanf("%s",st[n].sex);printf("基本工资:");scanf("%d",&st[n].salary.basic);printf("津贴:");scanf("%d",&st[n].salary.subsidy);printf("奖金:");scanf("%d",&st[n].salary.wages);st[n].salary.sum=st[n].salary.basic+st[n].salary.subsidy+st[n].salary.wages;printf("职工信息已成功录入\n");Print_MainInterface();}void Print_Interface_2(){int x;char s[50],y[50];printf("\n");printf("*************************逗比的分割线*************************\n");printf("\n");printf("1.查询所有职工\n");printf("2.按职工号查询\n");printf("3.按职工姓名查询\n");printf("4.返回主菜单\n");printf("请选择查找方式:\n");scanf("%d",&x);if (x==1)Print_staff();elseif (x==2){printf("请输入职工工号:");scanf("%s",y);Print_empl1(y);}elseif (x==3){printf("请输入职工姓名:");scanf("%s",s);Print_empl2(s);}elseif (x==4)Print_MainInterface();else{printf("输入命令错误, 返回上一层\n");Print_Interface_2();}}void Print_Interface_3(){char ch[10];printf("\n");qsort(1,n);printf("排序完毕!排序后结果请从查询全体职工处查看\n");Print_MainInterface();}void Print_Interface_4(){int i,All=0;char ch[10];printf("\n");for (i=1;i<=n;i++)All=All+st[i].salary.sum;printf("所有职工的总工资为:%d\n",All);printf("请输入任意字符并敲回车键返回主菜单\n");scanf("%s",&ch);Print_MainInterface();}void Print_Interface_5(){FILE *fp;char ch[10];int i;if ((fp=fopen("职工信息.txt","w"))==NULL){printf("cannot open this file\n");return ;}fprintf(fp,"%d\n",n);for (i=1;i<=n;i++)fprintf(fp,"%s %s %d %s %d %d %d\n",st[i].num,st[i].name,st[i].age,st[i].sex,st[i].salary.basic,st[i].salary.subsidy,st[i].salary.wages);fclose(fp);printf("\n");printf("已保存到文献\n");printf("\n");printf("请输入任意字符返回主菜单\n");scanf("%s",&ch);Print_MainInterface();}void Print_staff(){int i;printf("\n");printf("*************************帅比的分割线*************************");printf("\n");for (i=1;i<=n;i++){printf("职工工号:%s\n",st[i].num);printf("姓名:%s\n",st[i].name);printf("年龄:%d\n",st[i].age);printf("性别:%s\n",st[i].sex);printf("基本工资:%d\n",st[i].salary.basic);printf("津贴:%d\n",st[i].salary.subsidy);printf("奖金:%d\n",st[i].salary.wages);printf("总工资:%d\n",st[i].salary.sum);printf("\n");}printf("返回上一层\n");Print_Interface_2();}void Print_empl1(char x[]){int i,t,y,d=0;printf("\n");for (i=1;i<=n;i++)if (strcmp(x,st[i].num)==0){t=i;d=1;printf("职工工号:%s\n",st[i].num);printf("姓名:%s\n",st[i].name);printf("年龄:%d\n",st[i].age);printf("性别:%s\n",st[i].sex);printf("基本工资:%d\n",st[i].salary.basic);printf("津贴:%d\n",st[i].salary.subsidy);printf("奖金:%d\n",st[i].salary.wages);printf("总工资:%d\n",st[i].salary.sum);printf("\n");break;}if (d>0){printf("如需删除请按2,修改请按1,返回请按0\n");scanf("%d",&y);if (y==2)Print_delete(t);elseif (y==1)Print_Interface_2_1(t);elseif (y==0)Print_Interface_2();else{printf("输入命令错误, 返回上一层(再乱输入我找人打你啊)\n");Print_Interface_2();}}else{printf("对不起,查无此人(本系统不涉及路人甲乙丙, 不要乱输-_-!)\n");printf("请重新选择查询方式\n");Print_Interface_2();}}void Print_empl2(char s[]){int i,t,x,y=0;printf("\n");for (i=1;i<=n;i++)if (strcmp(s,st[i].name)==0){t=i;y=1;printf("职工工号:%s\n",st[i].num);printf("姓名:%s\n",st[i].name);printf("年龄:%d\n",st[i].age);printf("性别:%s\n",st[i].sex);printf("基本工资:%d\n",st[i].salary.basic);printf("津贴:%d\n",st[i].salary.subsidy);printf("奖金:%d\n",st[i].salary.wages);printf("总工资:%d\n",st[i].salary.sum);printf("\n");break;}if (y>0){printf("如需删除请按2,修改请按1,返回请按0(再乱输入我找人打你啊)\n");scanf("%d",&x);if (x==2)Print_delete(t);elseif (x==1)Print_Interface_2_1(t);elseif (x==0)Print_Interface_2();else{printf("输入命令错误, 返回上一层\n");Print_Interface_2();}}else{printf("对不起,查无此人(本系统不涉及路人甲乙丙, 不要乱输-_-!)\n");printf("请重新选择查询方式\n");Print_Interface_2();}}void Print_delete(int t){st[t].salary.sum=0;qsort(1,n);n--;printf("已删除该职工并排序, 自动返回主菜单\n");Print_MainInterface();}void Print_Interface_2_1(int t){int x;printf("\n");printf("请选择以下选项:\n");printf("1.职工号\n");printf("2.姓名\n");printf("3.年龄\n");printf("4.性别\n");printf("5.基本工资\n");printf("6.津贴\n");printf("7.奖金\n");printf("8.返回上一层\n");printf("9.返回主菜单\n");scanf("%d",&x);switch(x){case 1:scanf("%s",st[t].num);break;case 2:scanf("%s",st[t].name);break;case 3:scanf("%d",st[t].age);break;case 4:scanf("%s",st[t].sex);break;case 5:scanf("%s",st[t].salary.basic);break;case 6:scanf("%d",st[t].salary.subsidy);break;case 7:scanf("%d",st[t].salary.wages);break;}st[t].salary.sum=st[t].salary.basic+st[t].salary.subsidy+st[t].salary.wages;if (x<=8)Print_Interface_2();elseif (x==9)Print_MainInterface();}void qsort(int l,int r){int i,j,mid;employee tt;i=l;j=r;mid=st[(l+r)/2].salary.sum;do{while (st[i].salary.sum>mid) i++;while (st[j].salary.sum<mid) j--;if (i<=j){tt=st[i];st[i]=st[j];st[j]=tt;i++;j--;}}while(i<=j);if (i<r) qsort(i,r);if (l<j) qsort(l,j);}。

c语言课程实践《职工工资管理系统》源代码

c语言课程实践《职工工资管理系统》源代码
else if(mn==0)
fprintf(report,"\n\tAverage wage\t\t%.2f\t\t0.00\t\t%.2f",(float)(fsum/fn),(float)(fsum/fn));//如果男性人数是0,则只输出女性的平均工资
else
fprintf(report,"\n\tAverage wage\t\t%.2f\t\t%.2f\t\t%.2f",(float)(fsum/fn),(float)(msum/mn),(float)((fsum+msum)/(fn+mn)));//如果男女都不为0的话,那么则把平均工资都输出
p=temp;//temp指针变量往后移
temp=temp->next;//temp指针变量往后移
}
if(fnum==temp->num)//如果找到了,就执行下面的程序
{
find=1;//标记变量:find是1的时候说明找到,0则说明没找到
printf("\n");
unsigned int age; // 年龄
unsigned long telephone,wage,num; // 电话,工资,编号
struct workers *next; // 指向下一条记录的指针(链表使用)
};
struct workers *head,*bottom,*temp,*p;//定义指向结构体的指针变量
insert();//调用创建链表,录入信息的函数
}
getchar();//输入任意字符
return main();//返回主调函数
}

员工工资管理系统代码

员工工资管理系统代码
printf("实发工资:");
scanf("%s",employee.shi);
fseek (fp,0,SEEK_END); /*移动文件内部位置指针*/
fwrite(&employee,sizeof(EmployeeType),1,fp); /*将员工信息存入文件中*/
tag=tolower(tag); /*大写字母转化为小写字母*/
}
} while(tag=='y'); /*肯定回答时循环*/
}
fseek(fp,-sizeof(EmployeeType),SEEK_CUR); /*移动文件内部位置指针*/
fwrite(&employee,sizeof(EmployeeType),1,fp); /*输入数据*/
}break;
case 2: /*按员工姓名查询*/
printf("输入员工的姓名:\n");
scanf("%s",name);
rewind (fp); /*使指针位置返回到文件的开头*/
void ListDate(void); /*显示数据*/
void Pack(void); /*在物理上删除作有标记的记录*/
#endif
FILE *fp;
void AddData(void) /*增添数据*/
&& employee.status==0
)break;
fread (&employee,sizeof(EmployeeType),1,fp);
}
if(!feof(fp))
{ /*查询成功*/

职工工资管理源代码

职工工资管理源代码

附录〈源程序〉include <stdio.h>include <stdlib.h>include <string.h>struct worker{char name30;char ID10;int salary1;salary2;salary3;};int dqstruct worker wo;void show;void bcstruct worker wo;void add;void see;void search;void ghcz;void xmcz;void del;void xmsc;void ghsc;void statistics;void modify;void ghxg;void xmxg;void reserve;void back;void author;struct worker wo100; //保存所有的职工信息int Number=0; //记录总的职工人数void main{int choose=0;whiletrue{show;printf"\t\t====>请选择:";scanf"%d";&choose;system"cls";switchchoose{case 0: exit0;//退出break;case 1: add;back;//添加职工信息break;case 2: see;back;//查看职工信息break;case 3: search; back;// 查找职工信息break;case 4: del;back;//删除职工信息break;case 5: statistics; back;//统计职工工资break;case 6: modify; back;//修改职工信息break;case 7:reserve; back;//保存数据break;case 8:author; back;//作者信息break;default:break;}fflushstdin;getchar;system"cls";}}int dqstruct worker wo{FILE fp=NULL;int i=0;whilefread&woi;sizeofstruct worker;1;fp i++;fclosefp;return i;}void show{printf"\n";printf"\t职工工资管理系统\n\n";printf"\t☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆\n\n"; printf"\t^^^^^^^^^^^^^^^1 添加职工信息^^^^^^^^^^^^^^^^^\n"; printf"\t^^^^^^^^^^^^^^^2 查看职工信息^^^^^^^^^^^^^^^^^\n"; printf"\t^^^^^^^^^^^^^^^3 查找职工信息^^^^^^^^^^^^^^^^^\n"; printf"\t^^^^^^^^^^^^^^^4 删除职工信息^^^^^^^^^^^^^^^^^\n"; printf"\t^^^^^^^^^^^^^^^5 统计职工工资^^^^^^^^^^^^^^^^^\n"; printf"\t^^^^^^^^^^^^^^^6 修改职工信息^^^^^^^^^^^^^^^^^\n"; printf"\t^^^^^^^^^^^^^^^7 保存数据^^^^^^^^^^^^^^^^^\n"; printf"\t^^^^^^^^^^^^^^^8 作者信息^^^^^^^^^^^^^^^^^\n"; printf"\t^^^^^^^^^^^^^^^0 退出系统^^^^^^^^^^^^^^^^^\n\n"; printf"\t★★★★★★★★★★★★★★★★★★★★★★★\n"; }void bcstruct worker wo{FILE fp=NULL;fwritewo;sizeofstruct worker;1;fp;fclosefp;}//添加职工信息void add{int numberTemp=0;int i=0;struct worker temp;printf"请输入要添加职工个数:"; scanf"%d";&numberTemp;fori=0;i<numberTemp;i++{printf"输入第%d个职工信息\n";i+1; printf"姓名:";scanf"%s";;printf"工号:";scanf"%s";temp.ID;printf"基本工资:";scanf"%d";&temp.salary1;printf"职务工资:";scanf"%d";&temp.salary2;printf"津贴:";scanf"%d";&temp.salary3; woNumber++=temp; //写入到数组bc&temp; //写入到文件}printf"添加成功\n";}//查看职工信息void see{int i=0;printf"以下是全部职工\n";printf"\t姓名\t工号\t基本工资\t职务工资\t津贴\n";whilei<Number{printf"\t%s\t%s\t%d\t\t%d\t\t%d\n";;woi.ID;woi.salary1; woi.salary2;woi.salary3;i++;}}//查找职工信息void search{int n=0;printf"1 按姓名查找\n";printf"2 按工号查找\n";scanf"%d";&n;switchn{case 1: xmcz;break;case 2: ghcz;break;default: printf"输入错误\n";break;}}void xmcz//按姓名查找{char name30;int i=0;printf"请输入要查找职工姓名:";scanf"%s";name;system"cls";printf"\t姓名\t工号\t基本工资\t职务工资\t津贴\n";for i=0;i<Number;i++{if strcmpname;==0{printf"\t%s\t%s\t%d\t\t%d\t\t%d\n";;woi.ID;woi.salary1; woi.salary2;woi.salary3;}}void ghcz//按工号查找{char id10;int i=0;printf"请输入要查找职工工号:";scanf"%s";id;system"cls";printf"\t姓名\t工号\t基本工资\t职务工资\t津贴\n";for i=0;i<Number;i++{if strcmpid;woi.ID==0{printf"\t%s\t%s\t%d\t\t%d\t\t%d\n";;woi.ID;woi.salary1; woi.salary2;woi.salary3;}}}//删除职工信息void delint n=0;printf"1 按姓名删除\n";printf"2 按工号删除\n";scanf"%d";&n;switchn{case 1: xmsc;break;case 2: ghsc;break;}}void xmsc//按姓名删除{FILE fp=NULL;char name30;int i=0;int j=0;printf"请输入要删除的职工姓名:"; scanf"%s";name;fori=0;i<Number;i++{if strcmpname;==0{for j=i;j<Number-1;j++{woj=woj+1;}Number--;}}//将剩余数据写入文件擦除以前的数据for i=0;i<Number;i++{fwrite&woi;sizeofstruct worker;1;fp; }fclosefp;printf"删除成功;\n";}void ghsc//按工号删除{FILE fp=NULL;char id60;int i=0;int j=0;printf"请输入要删除的职工工号:"; scanf"%s";id;fori=0;i<Number;i++{if strcmpid;woi.ID==0{for j=i;j<Number-1;j++{woj=woj+1;}Number--;}}//将剩余数据写入文件擦除以前的数据for i=0;i<Number;i++{fwrite&woi;sizeofstruct worker;1;fp; }fclosefp;printf"删除成功;\n";}//统计职工工资void statistics{int i=0;double s=0.0;double sum100;fori=0;i<Number;i++{sumi=woi.salary1+woi.salary2+woi.salary3; printf"%s的总工资为:%f\n";;sumi; }fori=0;i<Number;i++{s+=sumi;}printf"平均工资为:%f\n";s/Number;}//修改职工信息void modify{int mode=0;printf"请选择修改查找方式\n"; printf"1 按姓名查找修改\n"; printf"2 按工号查找修改\n"; scanf"%d";&mode;switchmode{case 1: xmxg;break;case 2: ghxg;break;default: printf"输入错误\n"; break;}}void xmxg//按姓名修改{FILE fp=NULL;char name30;int i=0;printf"请输入要修改的职工姓名:"; scanf"%s";name;for i=0;i<Number;i++{if strcmpname;;elsebreak;}printf"\t姓名\t工号\t基本工资\t职务工资\t津贴\n";printf"\t%s\t%s\t%d\t\t%d\t\t%d\n";;woi.ID;woi.salary1; woi.salary2;woi.salary3;printf"请重新输入该职工信息";printf"姓名:";scanf"%s";;printf"工号:";scanf"%s";woi.ID;printf"基本工资:";scanf"%d";&woi.salary1;printf"职务工资:";scanf"%d";&woi.salary2;printf"津贴:";scanf"%d";&woi.salary3;//信息修改后重新更新文件里面的数据以保持数据一致性for i=0;i<Number;i++{fwrite&woi;sizeofstruct worker;1;fp;}fclosefp;}void ghxg//按工号修改{FILE fp=NULL;char id30;int i=0;printf"请输入要修改的职工工号:";scanf"%s";id;for i=0;i<Number;i++{if strcmpid;woi.ID;elsebreak;}printf"\t姓名\t工号\t基本工资\t职务工资\t津贴\n";printf"\t%s\t%s\t%d\t\t%d\t\t%d\n";;woi.ID;woi.salary1; woi.salary2;woi.salary3;printf"请重新输入该职工信息";printf"姓名:";printf"姓名:";scanf"%s";;printf"工号:";scanf"%s";woi.ID;printf"基本工资:";scanf"%d";&woi.salary1;printf"职务工资:";scanf"%d";&woi.salary2;printf"津贴:";scanf"%d";&woi.salary3;//信息修改后重新更新文件里面的数据以保持数据一致性for i=0;i<Number;i++{fwrite&woi;sizeofstruct worker;1;fp;}fclosefp;printf"\t=======>修改成功\n";}//保存数据void reserve{printf"\t=====程序在运行时已自动保存.....\n";}void back{printf"\t===>按Enter键返回主菜单\n";}//作者信息void author{printf"\t☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆\n\n"; printf"\t^^^^^^^^^^^^^^^学校名称^^^^^^^^^^^^^\n\n"; printf"\t^^^^^^^^^^^^^^学院班级^^^^^^^^^^^^^\n\n"; printf"\t^^^^^^^^^^^^^^^XXX制作^^^^^^^^^^^^^\n\n"; printf"\t★★★★★★★★★★★★★★★★\n\n";。

C++职工工资管理系统源代码

C++职工工资管理系统源代码

附录〈源程序〉#include <stdio.h>#include <stdlib.h>#include <string.h>struct worker{char name[30];char ID[10];int salary1,salary2,salary3;};int dq(struct worker wo[]);void show();void bc(struct worker wo[]);void add();void see();void search();void ghcz();void xmcz();void del();void xmsc();void ghsc();void statistics();void modify();void ghxg();void xmxg();void reserve();void back();void author();struct worker wo[100]; //保存所有的职工信息int Number=0; //记录总的职工人数void main(){int choose=0;while(true){show();printf("\t\t====>请选择:");scanf("%d",&choose);system("cls");switch(choose){case 0: exit(0);//退出break;case 1: add();back();//添加职工信息break;case 2: see();back();//查看职工信息break;case 3: search();back();// 查找职工信息break;case 4: del();back();//删除职工信息break;case 5: statistics();back();//统计职工工资break;case 6: modify();back();//修改职工信息break;case 7:reserve();back();//保存数据break;case 8:author();back();//作者信息break;default:break;}fflush(stdin);getchar();system("cls");}}int dq(struct worker wo[]){FILE *fp=NULL;int i=0;fp=fopen("C://worker.dat","rb");while(fread(&wo[i],sizeof(struct worker),1,fp)) i++;fclose(fp);return i;}void show(){printf("\n");printf("\t****************职工工资管理系统****************\n\n"); printf("\t*☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆*\n\n"); printf("\t^^^^^^^^^^^^^^^[1] 添加职工信息^^^^^^^^^^^^^^^^^\n"); printf("\t^^^^^^^^^^^^^^^[2] 查看职工信息^^^^^^^^^^^^^^^^^\n"); printf("\t^^^^^^^^^^^^^^^[3] 查找职工信息^^^^^^^^^^^^^^^^^\n"); printf("\t^^^^^^^^^^^^^^^[4] 删除职工信息^^^^^^^^^^^^^^^^^\n"); printf("\t^^^^^^^^^^^^^^^[5] 统计职工工资^^^^^^^^^^^^^^^^^\n"); printf("\t^^^^^^^^^^^^^^^[6] 修改职工信息^^^^^^^^^^^^^^^^^\n"); printf("\t^^^^^^^^^^^^^^^[7] 保存数据^^^^^^^^^^^^^^^^^\n"); printf("\t^^^^^^^^^^^^^^^[8] 作者信息^^^^^^^^^^^^^^^^^\n"); printf("\t^^^^^^^^^^^^^^^[0] 退出系统^^^^^^^^^^^^^^^^^\n\n"); printf("\t*★★★★★★★★★★★★★★★★★★★★★★★*\n"); }void bc(struct worker *wo){FILE *fp=NULL;fp=fopen("C://worker.dat","ab+");fwrite(wo,sizeof(struct worker),1,fp);fclose(fp);}//添加职工信息void add(){int numberTemp=0;int i=0;struct worker temp;printf("请输入要添加职工个数:");scanf("%d",&numberTemp);for(i=0;i<numberTemp;i++){printf("输入第%d个职工信息\n",i+1);printf("姓名:");scanf("%s",);printf("工号:");scanf("%s",temp.ID);printf("基本工资:");scanf("%d",&temp.salary1);printf("职务工资:");scanf("%d",&temp.salary2);printf("津贴:");scanf("%d",&temp.salary3);wo[Number++]=temp; //写入到数组bc(&temp); //写入到文件}printf("添加成功\n");}//查看职工信息void see(){int i=0;printf("以下是全部职工\n");printf("\t姓名\t工号\t基本工资\t职务工资\t津贴\n");while(i<Number){printf("\t%s\t%s\t%d\t\t%d\t\t%d\n",wo[i].name,wo[i].ID,wo[i].salary1,wo[i].sal ary2,wo[i].salary3);i++;}}//查找职工信息void search(){int n=0;printf("1 按姓名查找\n");printf("2 按工号查找\n");scanf("%d",&n);switch(n){case 1: xmcz();break;case 2: ghcz();break;default: printf("输入错误!\n");break;}}void xmcz()//按姓名查找{char name[30];int i=0;printf("请输入要查找职工姓名:");scanf("%s",name);system("cls");printf("\t姓名\t工号\t基本工资\t职务工资\t津贴\n");for (i=0;i<Number;i++){if (strcmp(name,wo[i].name)==0){printf("\t%s\t%s\t%d\t\t%d\t\t%d\n",wo[i].name,wo[i].ID,wo[i].salary1,wo[i].sal ary2,wo[i].salary3);}}}void ghcz()//按工号查找{char id[10];int i=0;printf("请输入要查找职工工号:");scanf("%s",id);system("cls");printf("\t姓名\t工号\t基本工资\t职务工资\t津贴\n");for (i=0;i<Number;i++){if (strcmp(id,wo[i].ID)==0){printf("\t%s\t%s\t%d\t\t%d\t\t%d\n",wo[i].name,wo[i].ID,wo[i].salary1,wo[i].sal ary2,wo[i].salary3);}}}//删除职工信息void del(){int n=0;printf("1 按姓名删除\n");printf("2 按工号删除\n");scanf("%d",&n);switch(n){case 1: xmsc();break;case 2: ghsc();break;}}void xmsc()//按姓名删除{FILE *fp=NULL;char name[30];int i=0;int j=0;printf("请输入要删除的职工姓名:");scanf("%s",name);for(i=0;i<Number;i++){if (strcmp(name,wo[i].name)==0){for (j=i;j<Number-1;j++){wo[j]=wo[j+1];}Number--;}}//将剩余数据写入文件擦除以前的数据fp=fopen("C://worker.dat","wb");for (i=0;i<Number;i++){fwrite(&wo[i],sizeof(struct worker),1,fp); }fclose(fp);printf("删除成功;\n");}void ghsc()//按工号删除{FILE *fp=NULL;char id[60];int i=0;int j=0;printf("请输入要删除的职工工号:");scanf("%s",id);for(i=0;i<Number;i++){if (strcmp(id,wo[i].ID)==0){for (j=i;j<Number-1;j++){wo[j]=wo[j+1];}Number--;}}//将剩余数据写入文件擦除以前的数据fp=fopen("C://worker.dat","wb");for (i=0;i<Number;i++){fwrite(&wo[i],sizeof(struct worker),1,fp);}fclose(fp);printf("删除成功;\n");}//统计职工工资void statistics(){int i=0;double s=0.0;double sum[100];for(i=0;i<Number;i++){sum[i]=wo[i].salary1+wo[i].salary2+wo[i].salary3; printf("%s的总工资为:%f\n",wo[i].name,sum[i]); }for(i=0;i<Number;i++){s+=sum[i];}printf("平均工资为:%f\n",s/Number);}//修改职工信息void modify(){int mode=0;printf("请选择修改查找方式\n");printf("1 按姓名查找修改\n");printf("2 按工号查找修改\n");scanf("%d",&mode);switch(mode){case 1: xmxg();break;case 2: ghxg();break;default: printf("输入错误!\n");break;}}void xmxg()//按姓名修改{FILE *fp=NULL;char name[30];int i=0;printf("请输入要修改的职工姓名:");scanf("%s",name);for (i=0;i<Number;i++){if (strcmp(name,wo[i].name));elsebreak;}printf("\t姓名\t工号\t基本工资\t职务工资\t津贴\n");printf("\t%s\t%s\t%d\t\t%d\t\t%d\n",wo[i].name,wo[i].ID,wo[i].salary1,wo[i].sal ary2,wo[i].salary3);printf("请重新输入该职工信息");printf("姓名:");scanf("%s",wo[i].name);printf("工号:");scanf("%s",wo[i].ID);printf("基本工资:");scanf("%d",&wo[i].salary1);printf("职务工资:");scanf("%d",&wo[i].salary2);printf("津贴:");scanf("%d",&wo[i].salary3);//信息修改后重新更新文件里面的数据以保持数据一致性fp=fopen("C://worker.dat","wb");for (i=0;i<Number;i++){fwrite(&wo[i],sizeof(struct worker),1,fp);}fclose(fp);}void ghxg()//按工号修改{FILE *fp=NULL;char id[30];int i=0;printf("请输入要修改的职工工号:");scanf("%s",id);for (i=0;i<Number;i++){if (strcmp(id,wo[i].ID));elsebreak;}printf("\t姓名\t工号\t基本工资\t职务工资\t津贴\n");printf("\t%s\t%s\t%d\t\t%d\t\t%d\n",wo[i].name,wo[i].ID,wo[i].salary1,wo[i].sal ary2,wo[i].salary3);printf("请重新输入该职工信息");printf("姓名:");printf("姓名:");scanf("%s",wo[i].name);printf("工号:");scanf("%s",wo[i].ID);printf("基本工资:");scanf("%d",&wo[i].salary1);printf("职务工资:");scanf("%d",&wo[i].salary2);printf("津贴:");scanf("%d",&wo[i].salary3);//信息修改后重新更新文件里面的数据以保持数据一致性fp=fopen("C://worker.dat","wb");for (i=0;i<Number;i++){fwrite(&wo[i],sizeof(struct worker),1,fp);}fclose(fp);printf("\t=======>修改成功\n");}//保存数据void reserve(){printf("\t=====程序在运行时已自动保存.....\n");}void back(){printf("\t===>按Enter键返回主菜单\n");}//作者信息void author(){printf("\t***☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆***\n\n"); printf("\t^^^^^^^^^^^^^^^学校名称^^^^^^^^^^^^^\n\n"); printf("\t^^^^^^^^^^^^^^学院班级^^^^^^^^^^^^^\n\n"); printf("\t^^^^^^^^^^^^^^^XXX制作^^^^^^^^^^^^^\n\n"); printf("\t***★★★★★★★★★★★★★★★★***\n\n");。

C++员工工资管理系统源代码

C++员工工资管理系统源代码

#include <iomanip>#include <iostream>#include <fstream>#include <malloc.h>#include <stdlib.h>#include <string.h>using namespace std;#define NULL 0#define LEN sizeof(struct student)int const N=20;void Menu();void Pass();int n=0; //定义一个全局变量统计职工人数//——--------->定义一个职工信息的结构体struct student{char name[N]; //用来存放姓名char sex[N]; //用来存放性别long id; //用来存放编号float paid[3]; //用来存放工资int total; //用来存放总工资struct student *next;};//-------------->职工类class Information{public:Information() ; //构造函数.~Information() ; //析构函数.student *creat(); //建立链表void output(student *head); //显示职工信息int count(student *head); //定义函数count()统计职工总数student *insert(student*head); //指针函数*insert()用来添加职工信息.student *cancel(student *head,long id); //指针函数*cancel()用来删除职工信息. student *find(student *head,long id); //指针函数*find()用来查找职工信息.student *modify(student *head,long id); //指针函数*modife()用来修改职工的信息.void paixu(student *head); //定义paixu()函数将职工的总额从大到小排列并输出void average(student *head); //定义职工工资平均值的函数void save(student *head); //保存文件信息student *Read(); //读取文件信息private:student *p1,*p2,*p3,*head,st;};Information::Information(){cout<<" ******************************************************************************\n";cout<<" ------------------------<<欢迎您使用员工工资管理系统>>------------------------\n";cout<<" ******************************************************************************\n\n";}Information::~Information(){ cout<<" ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤\n";cout<<" \n"; cout<<" 本系统管理员\n"; cout<<" \n"; cout<<" \n"; cout<<" ------------------------<<谢谢您使用员工工资管理系统>>------------------------\n";cout<<" \n"; cout<<" \n"; cout<<" 欢迎下次使用\n"; cout<<" \n"; cout<<" \n"; cout<<" 再见\n"; cout<<" \n"; cout<<" ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤\n";}//------------>建立链表信息student *Information::creat(void){//定义一个指向struct student的结构体指针函数*creat()用来录入职工信息.char ch[N];n=0; //用来存放职工姓名p1=p2=(student *)malloc(LEN);//调用malloc()函数用来开辟一个新的存储单元cout<<" -------------<<请建立员工信息表,在姓名处键以# 结束输入!>>--------------"<<endl;cout<<" 姓名:";cin>>ch;head=NULL; //给指针head赋初值while (strcmp(ch,"#")!=0){ //调用字符比较函数strcmp()用来判断是否继续输入p1=(student *)malloc(LEN); //调用malloc()函数用来开辟一个新的存储单元strcpy(p1->name,ch); //将循环结构前面输入的姓名复制到结构体名为p1的数组name中cout<<" 性别:";cin>>p1->sex;cout<<" 编号:";cin>>p1->id;while((p1->id)<0||(p1->id)>100000) //判断输入的编号是否有效(100000个){cout<<" 对不起您的输入错误!请重新输入(>0<1000000): ";cin>>p1->id;}cout<<" 基本工资:";cin>>p1->paid[0];while((p1->paid[0])<0||(p1->paid[0])>100000) //判断输入的分数是否有效(>=0 <=100000){cout<<" 对不起您的输入错误!请重新输入(>0<100000): ";cin>>p1->paid[0];}cout<<" 加班工资:";cin>>p1->paid[1];while((p1->paid[1])<0||(p1->paid[1])>100000) //判断输入的分数是否有效(>=0<=100000){cout<<" 对不起您的输入错误!请重新输入(>0<100000): ";cin>>p1->paid[1];}cout<<" 其他奖金:";cin>>p1->paid[2];while((p1->paid[2])<0||(p1->paid[2])>100000) //判断输入的分数是否有效(>=0 <=100000){cout<<" 对不起您的输入错误!请重新输入(>0<100000): ";cin>>p1->paid[2];}p1->total=p1->paid[0]+p1->paid[1]+p1->paid[2]; //计算总额if(n==0)head=p1; //如果是输入第一组职工信息就将指针p1赋给指针headelse p2->next=p1; //否则将p1赋给p2所指结构体的next指针p2=p1; //将指针p1赋给指针p2n++; //将职工人数n的值加1cout<<"\n 姓名:";cin>>ch; //将输入的姓名存放到字符数组ch中}p2->next=NULL; //将p2所指结构体的next指针重新赋空值return (head);//将输入的第一组职工信息返回}//--------------->定义output()函数将职工的信息从头指针所指内容开始输出void Information::output(student *head)system("cls");if(head==NULL) cout<<" 这是一个空表,请先输入员工信息!\n";else{cout<<"-------------------------------------------------------------------------------\n";cout<<" *职工工资信息表*\n";cout<<"-------------------------------------------------------------------------------\n";cout<<"|编号| |姓名| |性别| |基本工资| |加班工资| |其他奖金| |总额|\n"; cout<<"-------------------------------------------------------------------------------\n";p1=head; //将头指针赋给pdo{cout<<setw(6)<<p1->id<<setw(10)<<p1->name<<setw(10)<<p1->sex<<setw(10)<<p1->paid[0]<<setw(10)<<p1->paid[1]<<setw(12)<<p1->paid[2]<<setw(12)<<p1->total<<endl;cout<<"-------------------------------------------------------------------------------\n";p1=p1->next; //将下一组职工信息的next指针赋给p}while(p1!=NULL); //若指针p非空则继续,目的是把所有的职工信息都传给指针p然后输出.}//------------>统计职工人数的函数int Information::count(struct student *head) //定义函数count()统计职工总数{if(head==NULL)return(0); //若指针head为空返回值为0else return(1+count(head->next)); //函数的递归调用}//----------->添加职工的成绩的函数student *Information::insert( student *head)//插入新结点定义一个指向struct student的结构体指针函数*insert()用来添加职工信息. {system("cls");cout<<"\t----------------<<请输入新增员工信息>>----------------\n"<<endl;p1=(student *)malloc(LEN); //使p1指向插入的新结点cout<<" 编号:";cin>>p1->id;while((p1->id)<0||(p1->id)>100000){cout<<" 对不起您的输入错误!请重新输入(>0<100000): ";cin>>p1->id; //将输入的编号存放到p1所指结构体的数组id中}cout<<" 姓名:";cin>>p1->name; //将输入的姓名存放到结构体名为p1的数组name中cout<<" 性别:";cin>>p1->sex;cout<<" 基本工资:";cin>>p1->paid[0];while((p1->paid[0])<0||(p1->paid[0])>100000){cout<<" 对不起您的输入错误!请重新输入(>0<100000): ";cin>>p1->paid[0]; //将输入的基本工资存放到p1所指结构体的数组paid中}cout<<" 加班工资:";cin>>p1->paid[1];while((p1->paid[1])<0||(p1->paid[1])>100000){cout<<" 对不起您的输入错误!请重新输入(>0<100000): ";cin>>p1->paid[1]; //将输入的加班工资存放到p1所指结构体的数组paid中}cout<<" 其他奖金:";cin>>p1->paid[2];while((p1->paid[2])<0||(p1->paid[2])>100000){cout<<" 对不起您的输入错误!请重新输入(>0<100000): ";cin>>p1->paid[2]; //将输入的其他奖金存放到p1所指结构体的数组paid中}p1->total=p1->paid[0]+p1->paid[1]+p1->paid[2];//计算总分p2=head; //将头指针赋给p2if(head==NULL) //若没调用次函数以前的头指针head为空{head=p1;p1->next=NULL;} //则将p1赋给头指针head并将p1所指结构体成员指针next赋空值else{while((p1->id>p2->id)&&(p2->next!=NULL)){p3=p2; //p3指向原p2指向的结点p2=p2->next;} //p2后移一个结点if(p1->id<=p2->id){if(head==p2){p1->next=head;head=p1;} //插入到第一个结点之前else{p3->next=p1;p1->next=p2;} //插入到p3所指结点之后}else{p2->next=p1;p1->next=NULL;} //插入到尾结点之后}n++; //将职工人数加1cout<<"\t----------------<<你输入的员工信息已经成功插入>>----------------"<<endl; return (head);}//------------>删除职工信息student *Information::cancel(student *head,long id) //定义一个指向struct student的结构体指针函数*delete()用来删除考生信息.{system("cls");if(head==NULL) //若调用次函数以前的头指针head为空{return(head);}else{p1=head; //否则将头指针赋给p1while(id!=p1->id&&p1->next!=NULL) //寻找要删除的结点当p1所指的职工编号不是输入的职工编号并且p1所指的next指针不为空{p2=p1;p1=p1->next;} //p2指向原p1指向的结点p1后移一个结点if(id==p1->id) //如果输入的职工编号是p1所指的职工编号//结点找到后删除{if(p1==head) head=p1->next; //如果head指针和p1指针相等则将下一个结点赋给指针head elsep2->next=p1->next; //否则将p1所指结点赋给p2所指结点将要删除的职工信息跳过去cout<<" 删除编号为"<<id<<"的职工\n";n--; //将职工人数减1}return(head); //将头指针返回}}/**************************修改职工数据**************************/student *Information::modify(student *head,long id){system("cls");cout<<"\t----------------<<请输入须修改的员工工资信息>>----------------\n"<<endl;p1=(student *)malloc(LEN); //使p1指向输入的结点p1=head; //否则将头指针赋给p1while(id!=p1->id&&p1->next!=NULL)//寻找结点当p1所指的职工编号不是输入的职工编号并且p1所指的next指针不为空{p1=p1->next; //p2指向原p1指向的结点p1后移一个结点}if(id==p1->id) //如果要查找的职工编号是p1所指的职工编号{cout<<"你需要修改的员工信息如下:\n";cout<<"------------------------------------------------------------------------------\n";cout<<"|编号| |姓名| |性别| |基本工资| |加班工资| |其他奖金| |总额|\n";cout<<"------------------------------------------------------------------------------\n";cout<<setw(6)<<p1->id<<setw(10)<<p1->name<<setw(10)<<p1->sex<<setw(10)<<p1->paid[0]<<setw(10)<<p1->paid[1]<<setw(12)<<p1->paid[2]<<setw(12)<<p1->total<<endl;cout<<"------------------------------------------------------------------------------\n";cout<<" 编号:";cin>>p1->id;while((p1->id)<0||(p1->id)>100000){cout<<" 对不起您的输入错误!请重新输入(>0<100000): ";cin>>p1->id; //将输入的编号存放到p1所指结构体的数组id中}cout<<" 姓名:";cin>>p1->name; //将输入的姓名存放到结构体名为p1的数组name中cout<<" 性别:";cin>>p1->sex;cout<<" 基本工资:";cin>>p1->paid[0];while((p1->paid[0])<0||(p1->paid[0])>100000){cout<<" 对不起您的输入错误!请重新输入(>0<100000): ";cin>>p1->paid[0]; //将输入的基本工资存放到p1所指结构体的数组paid中}cout<<" 加班工资:";cin>>p1->paid[1];while((p1->paid[1])<0||(p1->paid[1])>100000){cout<<" 对不起您的输入错误!请重新输入(>0<100000): ";cin>>p1->paid[1]; //将输入的加班工资存放到p1所指结构体的数组paid中}cout<<" 其他奖金:";cin>>p1->paid[2];while((p1->paid[2])<0||(p1->paid[2])>100000){cout<<" 对不起您的输入错误!请重新输入(>0<100000): ";cin>>p1->paid[2]; //将输入的其他奖金存放到p1所指结构体的数组paid中}p1->total=p1->paid[0]+p1->paid[1]+p1->paid[2]; //计算总分}elsecout<<" 需要修改的信息中没有编号为"<<id<<"的员工.\n\n"; //没有想要修改的结点信息getchar();return(head);}//------------>查找职工信息student *Information::find(student *head,long id)//定义一个指向struct student的结构体指针函数*find()用来查找职工信息.{system("cls");if(head==NULL) //若调用次函数以前的头指针head为空{cout<<" 这是一个空表,请先输入员工信息!\n";return(head);}else{p1=head; //否则将头指针赋给p1while(id!=p1->id&&p1->next!=NULL)//寻找结点当p1所指的职工编号不是输入的职工编号并且p1所指的next指针不为空{p1=p1->next; //p2指向原p1指向的结点p1后移一个结点}if(id==p1->id) //如果要查找的职工编号是p1所指的职工编号{cout<<"------------------------------------------------------------------------------\n";cout<<"|编号| |姓名| |性别| |基本工资| |加班工资| |其他奖金| |总额|\n"; cout<<"------------------------------------------------------------------------------\n";cout<<setw(6)<<p1->id<<setw(10)<<p1->name<<setw(10)<<p1->sex<<setw(10)<<p1->paid[0]<<setw(10)<<p1->paid[1]<<setw(12)<<p1->paid[2]<<setw(12)<<p1->total<<endl;cout<<"------------------------------------------------------------------------------\n";}elsecout<<"信息中没有编号为"<<id<<"的员工.\n"; //结点没找到return(head);}}//------------定义paixu()函数将职工的工资总额从大到小排列并输出void Information::paixu(student *head){system("cls");int i,k,m=0,j;student *p[N];//定义一个指向struct student的结构体指针数组pif(head!=NULL)//如果头指针是空则继续{ m=count(head);cout<<"------------------------------------------------------------------------------\n";cout<<" *员工工资统计表*\n";cout<<"------------------------------------------------------------------------------\n";cout<<"|编号| |姓名| |性别| |基本工资| |加班工资| |其他奖金| |总额| |名次|\n"; cout<<"------------------------------------------------------------------------------\n";p1=head;for(k=0;k<m;k++){p[k]=p1;p1=p1->next;}for(k=0;k<m-1;k++) //选择排序法for(j=k+1;j<m;j++)if(p[k]->total<p[j]->total){p2=p[k];p[k]=p[j];p[j]=p2;} //从大到小排列的指针for(i=0;i<m;i++){cout<<setw(6)<<p[i]->id<<setw(8)<<p[i]->name<<setw(9)<<p[i]->sex<<setw(10)<<p[i]->paid[0]<<setw(10)<<p[i]->paid[1]<<setw(10)<<p[i]->paid[2]<<setw(10)<<p[i]->total<<setw(10)<<i+1<<endl;cout<<"------------------------------------------------------------------------------\n";}}}//------------>求各工资的平均值的函数void Information::average(student *head){int k,m;float arg1=0,arg2=0,arg3=0;if(head==NULL)//如果头指针是空则继续{cout<<" 这是一个空表,请先输入员工信息!\n";}else{m=count(head);p1=head;for(k=0;k<m;k++){arg1+=p1->paid[0];arg2+=p1->paid[1];arg3+=p1->paid[2];p1=p1->next;}arg1/=m;arg2/=m;arg3/=m;cout<<" *各项工资的平均值*\n";cout<<"------------------------------------------------------------------------------\n";cout<<"\t\t基本工资的平均值: "<<setw(4)<<arg1<<"\n"<<"\t\t加班工资的平均值: "<<setw(4)<<arg2<<"\n"<<"\t\t奖金的平均值: "<<setw(4)<<arg3<<"\n";cout<<"------------------------------------------------------------------------------\n";}}//------------------->保存函数.void Information::save(student *head){system("cls");ofstream out("data.txt",ios::out);out<<count(head)<<endl;while(head!=NULL){ out<<head->name<<"\t"<<head->id<<"\t"<<"\t"<<head->sex<<"\t"<<head->paid[0]<<"\t"<<head->paid[1]<<"\t"<<head->paid[2]<<"\t"<<head->total<<endl;head=head->next;}}//———————————>读取文件的信息student *Information::Read(){system("cls");int i=0;p1=p2=( student *)malloc(LEN);head=NULL;ifstream in("data.txt",ios::in);in>>i;if(i==0){cout<<" data 文件中的数据为空,请先输入数据!"<<endl; return 0;}else {cout<<"\n原文件已保存的信息如下:\n";cout<<" ………………………………………………………………………………………………" <<endl;cout<<"|姓名| |编号| |性别| |基本工资| |加班工资| |其他奖金| |总额|\n";cout<<" ………………………………………………………………………………………………" <<endl;for(;i>0;i--){p1=(student *)malloc(LEN);in>>>>st.id>>st.sex>>st.paid[0]>>st.paid[1]>>st.paid[2]>>st.total;strcpy(p1->name,);p1->id=st.id;strcpy(p1->sex,st.sex);p1->paid[0]=st.paid[0];p1->paid[1]=st.paid[1];p1->paid[2]=st.paid[2];p1->total=st.total;if(n==0)head=p1; //如果是输入第一组职工信息就将指针p1赋给指针headelse p2->next=p1; //否则将p1赋给p2所指结构体的next指针p2=p1; //将指针p1赋给指针p2n++; //将n的值加1//显示读入数据cout<<" "<<p1->name<<"\t"<<p1->id<<" \t"<< p1->sex <<" \t"<< p1->paid[0] <<" \t"<< p1->paid[1] <<" \t"<< p1->paid[2] <<" \t"<< p1->total<<endl;cout<<" ………………………………………………………………………………………………" <<endl;}cout<<" 数据已经成功读取完毕!\n\n"<<endl;p2->next=NULL;in.close();return (head);}}//-------------------->菜单void Menu(){Information person;student *head=NULL;int choice;long i;head=person.Read();do{cout<<"\t※※※※※※※※※※※※※※※※※※※※※※※※※"<<endl;cout<<"\t※"<<endl;cout<<"\t※_ _ _ 欢迎进入员工信息统计管理_ _ _ "<<endl;cout<<"\t※"<<endl;cout<<"\t※※※※※※※※※※※※※※※※※※※※※※※※※"<<endl;cout<<"\t "<<endl;cout<<"\t 相关操作选项"<<endl;cout<<"\t "<<endl;cout<<"\t※※※※※※※※※※※※※※※※※※※※※※※※※"<<endl;cout<<"\t※※"<<endl;cout<<"\t※※"<<endl;cout<<"\t※ 1. 员工数据输入※"<<endl;cout<<"\t※※"<<endl;cout<<"\t※ 2. 显示员工工资※"<<endl;cout<<"\t※※"<<endl;cout<<"\t※ 3. 排序统计工资※"<<endl;cout<<"\t※※"<<endl;cout<<"\t※ 4. 查找员工工资※"<<endl;cout<<"\t※※"<<endl;cout<<"\t※ 5. 增加员工工资※"<<endl;cout<<"\t※※"<<endl;cout<<"\t※ 6. 删除员工工资※"<<endl; cout<<"\t※※"<<endl;cout<<"\t※7. 修改员工信息※"<<endl; cout<<"\t※※"<<endl;cout<<"\t※8. 成功保存信息※"<<endl;cout<<"\t※※"<<endl;cout<<"\t※9. 安全退出系统※"<<endl; cout<<"\t※※"<<endl;cout<<"\t※※※※※※※※※※※※※※※※※※※※※※※※※※※\n"<<endl; cout<<" 请输入您的选择(0--9):";cin>>choice;while(choice<0||choice>9){cout<<" 对不起您的输入错误!请输入您的选择(0--9): ";cin>>choice;}//head=person.Read();switch(choice){case 1:head=person.creat();break;case 2://head=person.Read();person.output(head);break;case 3://head=person.Read();person.paixu(head); person.average(head);cout<<" 参加工作的员工人数为:"<<person.count(head)<<"人\n\n";break;case 4://head=person.Read();cout<<" 请输入要查找的编号:";cin>>i;while(i<0||i>100000){cout<<" 对不起您的输入错误!请重新输入: ";cin>>i;}person.find(head,i);break;case 5://head=person.Read();head=person.insert(head);person.output(head);break;case 6://head=person.Read();cout<<" 请输入要删除的编号:";cin>>i;while(i<0||i>100000){cout<<" 对不起您的输入错误!请重新输入: ";cin>>i;}head=person.cancel(head,i);person.output(head);break;case 7://head=person.Read();cout<<" 请输入要修改的编号:";cin>>i;while(i<0||i>100000){cout<<" 对不起您的输入错误!请重新输入: ";cin>>i;}person.modify(head,i);break;case 8:cout<<"信息已经成功保存!"<<endl;person.save(head);break;case 9:system("cls");break;default :cout<<" 对不起您的输入有误!请重新输入:\n";break;}}while(choice!=9);}//----------------->管理员登陆void Pass(){char UserName[30];char Passward[20];int i=0;cout<<"****************************************************************************\n";cout<<"\n\t为保护员工信息,只有管理员才可以进行管理!\n";cout<<"\n\t管理员名和登陆密码都只有4次机会,如果超过将自动退出系统!\n\n";cout<<"****************************************************************************\n";cout<<"\n请输入管理员名:";cin>>UserName;while (strcmp(UserName,"1")!=0){if(i>=3)exit(0); //超过4次则登陆失败,退出系统i++;cout<<"\n管理员名无效!请重新输入:";cin>>UserName;}cout<<"\n请输入密码:";cin>>Passward;while(strcmp(Passward,"1")!=0){if(i>=3)exit(0); //超过4次则登陆失败,退出系统i++;cout<<"\n密码输入错误!请重新输入:"<<endl; cin>>Passward;}cout<<"\n\t\t欢迎管理员的到来!!!!!\n"<<endl;}//------------------------------>主函数.int main(void){//设置背景色和字体颜色system("PAUSE"); //系统暂停system("cls"); //系统清屏Pass();system("PAUSE");system("cls");Menu();return 0; }//。

工资管理系统源代码

工资管理系统源代码

#include <stdio.h>#include <string.h>#include <ctype.h>#include <stdlib.h>#include <windows.h>#define MONTH_NUM 5 /* 最多的月份*/struct worker{int number; /* 每个工人的工号*/char name[15]; /* 每个工人的姓名*/int salary[MONTH_NUM]; /* 每个工人M月的工资*/ int sum; /* 每个工人的总工资*/ float average; /* 每个工人的平均工资*/ struct worker *next; //下一个节点的地址};typedef struct worker STU;char Menu(void);int Ascending(int a, int b);int Descending(int a, int b);void IntSwap(int *pt1, int *pt2);void CharSwap(char *pt1, char *pt2);void FloatSwap(float *pt1, float *pt2);STU *AppendNode(STU *head, const int m);STU *DeleteNode(STU *head, int nodeNum);STU *ModifyNode(STU *head, int nodeNum, const int m); STU *SearchNode(STU *head, int nodeNum);STU *Appendsalary(STU *head, const int m);void Totalsalary(STU *head, const int m);void Printsalary(STU *head, const int m);STU *Deletesalary(STU *head, const int m);void Modifysalary(STU *head, const int m);void Sortsalary(STU *head, const int m, int (*compare)(int a, int b));void Searchsalary(STU *head, const int m);void DeleteMemory(STU *head);void numberSwap(STU *head);main(){char ch,b;int m,a;STU *head = NULL;printf("\n\n\n\n\n\n\n\n\n");printf("``╭╮╭╮╭╮\n");printf("``│││││└╮\n");printf("╭┴┴———————┴┴╮~└—╯\n");printf("││╭—————╮\n");printf("│││哈│\n");printf("│●●│╭╮│喽! │\n");printf("│○╰┬┬┬╯○│o╰╯╰—————╯\n");printf("│╰—╯│\n");printf("╰——┬o———o┬——╯\n");printf(" ╭╮╭╮\n");printf(" ╰┴————┴╯\n");Sleep(3000);system("cls");printf("\n\n\n\n\n\n\n\n\n\n\n ≈~☆输入要记录的月份个数(m<10)☆~~`≈: "); scanf("%d", &m);system("cls");while (1){ch = Menu();switch (ch){case'1':head = Appendsalary(head, m);Totalsalary(head, m);break;case'2':Modifysalary(head, m);Totalsalary(head, m);printf("\nAfter modified\n");Printsalary(head, m);Sleep(1000);break;case'3':head = Deletesalary(head, m);printf("\nAfter deleted\n");Printsalary(head, m);break;case'4':do{Searchsalary(head, m);printf("\(≧▽≦)/ 是否要继续查询?Y or N:");scanf(" %c",&b);}while(b=='y'||b=='Y');break;case'5':Printsalary(head, m);printf("\(≧▽≦)/ 是否要选择排列方式?Y or N:");scanf(" %c",&b);while(b=='y'||b=='Y'){printf("你想降序排列还是升序排列?(1降序2升序):");scanf(" %d",&a);if(a==1){Sortsalary(head, m, Descending);printf("\nsorted in descending order by sum\n");Printsalary(head, m);}else{Sortsalary(head, m, Ascending);printf("\nsorted in ascending order by sum\n");Printsalary(head, m);}printf("O(∩_∩)O 是否继续选择排列方式?Y or N:");scanf(" %c",&b);}break;case'0':system("cls");printf("┴┬┴┬/ ̄\_/ ̄\\n");printf("┬┴┬┴▏▏▔▔▔▔\\n");printf("┴┬┴/\/﹨\n");printf("┬┴∕/)╭—————╮\n"); printf("┴┬▏●▏│再│\n"); printf("┬┴▏▔█◤╭╮│见! │\n"); printf("┴◢██◣\__/o╰╯╰—————╯\n"); printf("┬█████◣/\n");printf("┴█████████████◣\n");printf("◢██████████████▆▄\n");printf("◢██████████████▆▄\n");printf("█◤◢██◣◥█████████◤\\n");printf("◥◢████████████◤\\n");printf("┴███████████◤﹨\n");printf("┬││█████◤▏\n");printf("┴││)\n");printf("┬∕∕/▔▔▔\∕\n");printf("*∕___/﹨∕\/\\n");printf("┬┴┬┴┬┴\\_ ﹨/﹨\n");printf("┴┬┴┬┴┬┴\___\﹨/▔\﹨\n");exit(0);DeleteMemory(head);printf("End of program!");break;default:printf("Input error!");break;}}}char Menu(void)//主菜单{char ch;system("cls");printf("\n\n\n\n ━━●●━━━━━━━━━━━管理工人的工资━━━━━━...........(╯3╰)\n");printf(" 1.添加记录\n");printf(" 2.更新记录\n");printf(" 3.删除记录\n");printf(" 4.查询记录\n");printf(" 5.统计分析记录\n");printf(" 0.退出\n");printf(" ━━━━━━━━━━☆━━━━━━━━━━━━━━━━━☆━━━━━━━━━━\n");printf("` `.~ ☆~~`≈~☆☆~~`≈~☆☆~~`≈~☆.` `.~\n");printf("\n请输入你的选择:");scanf(" %c", &ch); /*在%c前面加一个空格,将存于缓冲区中的回车符读入*/system("cls");return ch;}STU *Appendsalary(STU *head, const int m)//添加新记录{int i = 0;char c;do{head = AppendNode(head, m); /*向链表末尾添加一个节点*/printf("\n O(∩_∩)O 你想再添加一个新的记录吗(Y/N)?");scanf(" %c",&c); /*%c前面有一个空格*/i++;}while (c=='Y' || c=='y');printf("%d new nodes have been apended!\n", i);return head;}STU *Deletesalary(STU *head, const int m)//删除记录{int i = 0, nodeNum;char c;do{printf("\n ⊙﹏⊙请输入你想删除的记录编号:");scanf("%d", &nodeNum);head = DeleteNode(head, nodeNum); /*删除工号为nodeNum的工人信息*/ Printsalary(head, m); /*显示当前链表中的各节点信息*/printf("Do you want to delete a node(Y/N)?");scanf(" %c",&c); /*%c前面有一个空格*/i++;}while (c=='Y' || c=='y');printf("%d nodes have been deleted!\n", i);return head;}void Modifysalary(STU *head, const int m)//修改记录{int i = 0, nodeNum;char c;do{printf("\n~~~^_^~~~ 请输入你想修改的记录编号:");scanf("%d", &nodeNum);head = ModifyNode(head, nodeNum, m); /*修改工号为nodeNum的节点*/ printf("Do you want to modify a node(Y/N)?");scanf(" %c",&c); /*%c前面有一个空格*/ i++;}while (c=='Y' || c=='y');printf("%d nodes have been modified!\n", i);}void Totalsalary(STU *head, const int m){STU *p = head;int i;while (p != NULL) /*若不是表尾,则循环*/{p->sum = 0;for (i=0; i<m; i++){p->sum += p->salary[i];}p->average = (float)p->sum / m;p = p->next; /*让p指向下一个节点*/}}void Sortsalary(STU *head, const int m, int (*compare)(int a, int b)){STU *pt;int flag = 0, i;do{flag = 0 ;pt = head;/*若后一个节点的总工资比前一个节点的总工资高,则交换两个节点中的数据注意只交换节点数据,而节点顺序不变,即节点next指针内容不进行交换*/ while (pt->next != NULL){if ((*compare)(pt->next->sum, pt->sum)){IntSwap(&pt->number, &pt->next->number);CharSwap(pt->name, pt->next->name);for (i=0; i<m; i++){IntSwap(&pt->salary[i], &pt->next->salary[i]);}IntSwap(&pt->sum, &pt->next->sum);FloatSwap(&pt->average, &pt->next->average);flag = 1;}pt = pt->next;}}while(flag);}/*交换两个整型数*/void IntSwap(int *pt1, int *pt2){int temp;temp = *pt1;*pt1 = *pt2;*pt2 = temp;}/*交换两个实型数*/void FloatSwap(float *pt1, float *pt2){float temp;temp = *pt1;*pt1 = *pt2;*pt2 = temp;}/*交换两个字符串*/void CharSwap(char *pt1, char *pt2){char temp[15];strcpy(temp, pt1);strcpy(pt1, pt2);strcpy(pt2, temp);}/*决定数据是否按升序排序,a<b为真,则按升序排序*/ int Ascending(int a, int b){return a < b;}/* 决定数据是否按降序排序,a>b为真,则按降序排序*/ int Descending(int a, int b){return a > b;}void Searchsalary(STU *head, const int m)//查询记录{int number, i,j,k=0,x,t=0;char str[100] = {'\0'}, temp[3];STU *findNode;printf("\n 请输入你想查找的记录编号:");scanf("%d", &number);findNode = SearchNode(head, number);if (findNode == NULL){printf("Not found!\n");}else{strcat(str, "工号");for(j=0;j<=strlen(findNode->name);j++)strcat(str," ");strcat(str, "姓名");for (i=1; i<=m; i++){if(findNode->salary[i]/10) t++;for(x=0;x<2*t;x++)strcat(str," ");strcat(str, "工资");itoa(i,temp, 10);strcat(str, temp);}strcat(str," 已发工资总和");if(findNode->sum/10) k++;for(i=0;i<k;i++)strcat(str," ");strcat(str," 个人平均工资");printf("%s", str);printf("\nNo.%3d %-8s ", findNode->number, findNode->name); for (i=0; i<m; i++){printf("%-7d ", findNode->salary[i]);}printf("%9d %9.2f\n", findNode->sum, findNode->average);}}void Printsalary(STU *head, const int m){STU *p = head;char str[100] = {'\0'}, temp[3];int i, j = 1,k,x,n=0,t=0;strcat(str, "工号");for(k=0;k<=strlen(p->name);k++)strcat(str," ");strcat(str, "姓名");for (i=1; i<=m; i++){if(p->salary[i]/10) t++;for(x=0;x<2*t;x++)strcat(str," ");strcat(str, "工资");itoa(i,temp, 10);strcat(str, temp);}strcat(str," 已发工资总和");if(p->sum/10) n++;for(k=0;k<n;k++)strcat(str," ");strcat(str," 个人平均工资");printf("%s", str); /* 打印表头*/while (p != NULL) /*若不是表尾,则循环打印*/{printf("\nNo.%3d %-8s ", p->number, p->name);for (i=0; i<m; i++){printf("%-7d ", p->salary[i]);}printf("%9d %9.2f\n", p->sum, p->average);p = p->next; /*让p指向下一个节点*/j++;}printf("\n");}STU *AppendNode(STU *head, const int m){STU *p = NULL;STU *pr = head;int j;p = (STU *)malloc(sizeof(STU)); /*为新添加的节点申请内存*/if (p == NULL) /*若申请内存失败,则打印错误信息,退出程序*/ {printf("No enough memory to alloc");exit(0);}if (head == NULL) /*若原链表为空表,则将新建节点置为首节点*/ {head = p;}else /*若原链表为非空,则将新建节点添加到表尾*/{/*若未到表尾,则继续移动指针pr,直到pr指向表尾*/while (pr->next != NULL){pr = pr->next;}pr->next = p; /*将新建节点添加到链表的末尾*/}pr = p; /*让pr指向新建节点*/printf("Input node data......");printf("\nInput number:");scanf("%d", &p->number);printf("Input name:");scanf("%s", p->name);for (j=0; j<m; j++){printf("Input salary%d:", j+1);scanf("%d", p->salary+j);}pr->next = NULL; /*将新建节点置为表尾*/return head; /*返回添加节点后的链表的头节点指针*/ }STU *ModifyNode(STU *head, int nodeNum, const int m){int j;STU *newNode;newNode = SearchNode(head, nodeNum);if (newNode == NULL){printf("Not found!\n");}else{printf("Input the new node data:\n");printf("Input name:");scanf("%s", newNode->name);for (j=0; j<m; j++){printf("Input salary%d:", j+1);scanf("%d", newNode->salary+j);}}return head;}STU *DeleteNode(STU *head, int nodeNum){STU *p = head, *pr = head;if (head == NULL) /*链表为空,没有节点,无法删除节点*/{printf("No Linked Table!\n");return(head);}/*若没找到节点nodeNum且未到表尾,则继续找*/while (nodeNum != p->number && p->next != NULL){pr = p;p = p->next;}if (nodeNum == p->number) /*若找到节点nodeNum,则删除该节点*/{if (p == head) /*若待删节点为首节点,则让head指向第2个节点*/{head = p->next;}else /*若待删节点非首节点,则将前一节点指针指向当前节点的下一节点*/ {pr->next = p->next;}free(p); /*释放为已删除节点分配的内存*/}else /*没有找到待删除节点*/{printf("This Node has not been found!\n");}return head; /*返回删除节点后的链表的头节点指针*/}STU *SearchNode(STU *head, int nodeNum){STU *p = head;int j = 1;while (p != NULL) /*若不是表尾,则循环*/{if (p->number == nodeNum) return p;p = p->next; /*让p指向下一个节点*/j++;}return NULL;}void DeleteMemory(STU *head){STU *p = head, *pr = NULL;while (p != NULL) /*若不是表尾,则释放节点占用的内存*/ {pr = p; /*在pr中保存当前节点的指针*/p = p->next; /*让p指向下一个节点*/free(pr); /*释放pr指向的当前节点占用的内存*/}}。

员工工资管理系统源代码

员工工资管理系统源代码

#include<stdio.h>#include<string.h>typedef struct{int basic;//基本工资int position;//岗位工资int subsidy;//津贴int wages;//奖金int sum;//总工资}money;typedef struct{char num[20];//职工号char name[20];//姓名int age;//年龄char sex[20];//性别money salary;//工资}employee;int Print_jinru();//账号密码输入void Fscan_information();//“职工信息.txt”文件写入void Print_staff();//全体员工void Print_empl1(char x[51]);//按职工号查询void Print_empl2(char s[51]);//按姓名查询void Print_MainInterface();//主界面void Print_Interface_1();//职工信息录入界面void Print_Interface_2();//职工信息查询界面void Print_Interface_3();//职工工资排序界面void Print_Interface_4();//职工总工资void Print_Interface_5();//文件读出void qsort(int l,int r);//快速排序void Print_delete(int t);//删除职工信息void Print_Interface_2_1(int t);//职工信息修改界面int fyanzheng(char s1[],char s2[]);//密码验证函数employee st[500];//记录职工信息的函数int n;//职工总数void main(){int x;employee em;printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@\n");printf("@@@@ 欢迎使用员工工资管理系统@@@@\n");printf("@@@@ 制作人:刘爽@@@@\n");printf("@@@@在使用中产生的任何问题,欢迎进行批评指正@@@@\n");printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@@\n");printf("\n");printf("\n");printf("\n");if (Print_jinru()){Fscan_information();Print_MainInterface();}else return;}void Fscan_information(){FILE *fp;int i;if ((fp=fopen("职工信息.txt","r"))==NULL){printf("cannot open this file\n");return ;}fscanf(fp,"%d",&n);for (i=1;i<=n;i++){fscanf(fp,"%s%s%d%s%d%d%d",st[i].num,st[i].name,&st[i].age,st[i].sex,&st[i].salary.basic, &st[i].salary.subsidy,&st[i].salary.wages);st[i].salary.sum=st[i].salary.basic+st[i].salary.subsidy+st[i].salary.wages;}fclose(fp);}int fyanzheng(char s1[],char s2[]){FILE *fp1,*fp2;char str1[40]="",str2[40]="",st;int t;if ((fp1=fopen("账号验证.in","r"))==NULL){printf("cannot open this file\n");return 0;}t=0;st=fgetc(fp1);while (st!='#'){str1[t]=st;t++;st=fgetc(fp1);}if ((fp2=fopen("密码验证.in","r"))==NULL){printf("cannot open this file\n");return 0;}t=0;st=fgetc(fp2);while (st!='#'){str2[t]=st;t++;st=fgetc(fp2);}fclose(fp1);fclose(fp2);if ((strcmp(str1,s1)==0)&&(strcmp(str2,s2)==0)) return 1;elsereturn 0;}int Print_jinru(){int f,d;char x[20],y[20];f=0;d=0;while(1){printf("请输入账号:");scanf("%s",x);getchar();printf("请输入密码:");scanf("%s",y);getchar();f=fyanzheng(x,y);if (d>3){printf("错误次数太多,退出系统\n");return 0;}if (f>0) break;else{printf("账号或密码输入错误,请重新输入\n");d++;}}printf("\n");printf("欢迎进入员工工资管理系统!!!\n");return 1;}void Print_MainInterface(){int x;printf("\n");printf("*************************华丽的分割线*************************\n");printf("\n");printf("1.职工信息录入\n");printf("2.职工信息查询\n");printf("3.职工工资排序\n");printf("4.统计职工总工资\n");printf("5.保存到文件\n");printf("6.退出职工工资系统\n");printf("请选择所需操作:");scanf("%d",&x);if (x==1)Print_Interface_1();elseif (x==2)Print_Interface_2();elseif (x==3)Print_Interface_3();elseif (x==4)Print_Interface_4();elseif (x==5)Print_Interface_5();elseif (x==6){printf(" ****** **** **** * * ***** * *\n");printf("* * * * * * * * * * *\n");printf("* * * * * * * * * * *\n");printf(" ****** ******** ******** ** * * * *\n");printf(" * * * ** * * * *\n");printf(" * * * ** * * * *\n");printf(" ****** **** **** ** ***** ***** \n");// printf("233333333333333333333333333333333333333333333333333333\n");return;}else{printf("输入命令错误,返回主菜单(再乱输入我找人打你啊)\n");Print_MainInterface();}}void Print_Interface_1(){n++;if (n>500){printf("超出职工最大数\n");Print_MainInterface();}printf("\n");printf("*************************妖精的分割线*************************\n");printf("\n");printf("新建职工号:");scanf("%s",st[n].num);printf("姓名:");scanf("%s",st[n].name);printf("年龄:");scanf("%d",&st[n].age);printf("性别:");scanf("%s",st[n].sex);printf("基本工资:");scanf("%d",&st[n].salary.basic);printf("津贴:");scanf("%d",&st[n].salary.subsidy);printf("奖金:");scanf("%d",&st[n].salary.wages);st[n].salary.sum=st[n].salary.basic+st[n].salary.subsidy+st[n].salary.wages;printf("职工信息已成功录入\n");Print_MainInterface();}void Print_Interface_2(){int x;char s[50],y[50];printf("\n");printf("*************************逗比的分割线*************************\n");printf("\n");printf("1.查询所有职工\n");printf("2.按职工号查询\n");printf("3.按职工姓名查询\n");printf("4.返回主菜单\n");printf("请选择查找方式:\n");scanf("%d",&x);if (x==1)Print_staff();elseif (x==2){printf("请输入职工工号:");scanf("%s",y);Print_empl1(y);}elseif (x==3){printf("请输入职工姓名:");scanf("%s",s);Print_empl2(s);}elseif (x==4)Print_MainInterface();else{printf("输入命令错误,返回上一层\n");Print_Interface_2();}}void Print_Interface_3(){char ch[10];printf("\n");qsort(1,n);printf("排序完成!排序后结果请从查询全体职工处查看\n");Print_MainInterface();}void Print_Interface_4(){int i,All=0;char ch[10];printf("\n");for (i=1;i<=n;i++)All=All+st[i].salary.sum;printf("所有职工的总工资为:%d\n",All);printf("请输入任意字符并敲回车键返回主菜单\n");scanf("%s",&ch);Print_MainInterface();}void Print_Interface_5(){FILE *fp;char ch[10];int i;if ((fp=fopen("职工信息.txt","w"))==NULL){printf("cannot open this file\n");return ;}fprintf(fp,"%d\n",n);for (i=1;i<=n;i++)fprintf(fp,"%s %s %d %s %d %d %d\n",st[i].num,st[i].name,st[i].age,st[i].sex,st[i].salary.basi c,st[i].salary.subsidy,st[i].salary.wages);fclose(fp);printf("\n");printf("已保存到文件\n");printf("\n");printf("请输入任意字符返回主菜单\n");scanf("%s",&ch);Print_MainInterface();}void Print_staff(){int i;printf("\n");printf("*************************帅比的分割线*************************");printf("\n");for (i=1;i<=n;i++){printf("职工工号:%s\n",st[i].num);printf("姓名:%s\n",st[i].name);printf("年龄:%d\n",st[i].age);printf("性别:%s\n",st[i].sex);printf("基本工资:%d\n",st[i].salary.basic);printf("津贴:%d\n",st[i].salary.subsidy);printf("奖金:%d\n",st[i].salary.wages);printf("总工资:%d\n",st[i].salary.sum);printf("\n");}printf("返回上一层\n");Print_Interface_2();}void Print_empl1(char x[]){int i,t,y,d=0;printf("\n");for (i=1;i<=n;i++)if (strcmp(x,st[i].num)==0){t=i;d=1;printf("职工工号:%s\n",st[i].num);printf("姓名:%s\n",st[i].name);printf("年龄:%d\n",st[i].age);printf("性别:%s\n",st[i].sex);printf("基本工资:%d\n",st[i].salary.basic);printf("津贴:%d\n",st[i].salary.subsidy);printf("奖金:%d\n",st[i].salary.wages);printf("总工资:%d\n",st[i].salary.sum);printf("\n");break;}if (d>0){printf("如需删除请按2,修改请按1,返回请按0\n");scanf("%d",&y);if (y==2)Print_delete(t);elseif (y==1)Print_Interface_2_1(t);elseif (y==0)Print_Interface_2();else{printf("输入命令错误,返回上一层(再乱输入我找人打你啊)\n");Print_Interface_2();}}else{printf("对不起,查无此人(本系统不包括路人甲乙丙,不要乱输-_-!)\n");printf("请重新选择查询方式\n");Print_Interface_2();}}void Print_empl2(char s[]){int i,t,x,y=0;printf("\n");for (i=1;i<=n;i++)if (strcmp(s,st[i].name)==0){t=i;y=1;printf("职工工号:%s\n",st[i].num);printf("姓名:%s\n",st[i].name);printf("年龄:%d\n",st[i].age);printf("性别:%s\n",st[i].sex);printf("基本工资:%d\n",st[i].salary.basic);printf("津贴:%d\n",st[i].salary.subsidy);printf("奖金:%d\n",st[i].salary.wages);printf("总工资:%d\n",st[i].salary.sum);printf("\n");break;}if (y>0){printf("如需删除请按2,修改请按1,返回请按0(再乱输入我找人打你啊)\n");scanf("%d",&x);if (x==2)Print_delete(t);elseif (x==1)Print_Interface_2_1(t);elseif (x==0)Print_Interface_2();else{printf("输入命令错误,返回上一层\n");Print_Interface_2();}}else{printf("对不起,查无此人(本系统不包括路人甲乙丙,不要乱输-_-!)\n");printf("请重新选择查询方式\n");Print_Interface_2();}}void Print_delete(int t){st[t].salary.sum=0;qsort(1,n);n--;printf("已删除该职工并排序,自动返回主菜单\n");Print_MainInterface();}void Print_Interface_2_1(int t){int x;printf("\n");printf("请选择以下选项:\n");printf("1.职工号\n");printf("2.姓名\n");printf("3.年龄\n");printf("4.性别\n");printf("5.基本工资\n");printf("6.津贴\n");printf("7.奖金\n");printf("8.返回上一层\n");printf("9.返回主菜单\n");scanf("%d",&x);switch(x){case 1:scanf("%s",st[t].num);break;case 2:scanf("%s",st[t].name);break;case 3:scanf("%d",st[t].age);break;case 4:scanf("%s",st[t].sex);break;case 5:scanf("%s",st[t].salary.basic);break;case 6:scanf("%d",st[t].salary.subsidy);break;case 7:scanf("%d",st[t].salary.wages);break;}st[t].salary.sum=st[t].salary.basic+st[t].salary.subsidy+st[t].salary.wages;if (x<=8)Print_Interface_2();elseif (x==9)Print_MainInterface();}void qsort(int l,int r){int i,j,mid;employee tt;i=l;j=r;mid=st[(l+r)/2].salary.sum;do{while (st[i].salary.sum>mid) i++;while (st[j].salary.sum<mid) j--;if (i<=j){tt=st[i];st[i]=st[j];st[j]=tt;i++;j--;}}while(i<=j);if (i<r) qsort(i,r);if (l<j) qsort(l,j);}。

员工工资管理系统源代码

员工工资管理系统源代码

# mclude<stdio.h>#mclude<string.h>tvpedef stmct{int basic; 〃基本工资int position;// 岗位工资int subsidy;// 津贴int wages;// 奖金int sum;//总工资}money;tvpedef stmct{chai- num[20];// 职工号clw naine[20]y/姓名int age;//年龄char sex[20];//性别money salary;〃工资} employee;mt PrintjiniuQ^/账号密码输入void Fscan_infoiniationO;// “职工信息.txt” 文件写入void Piiiit_staffQ;//全体员Tvoid Prmt_empll(chai- x[5!]);//按职工号查询void Priiit_empl2(char s[5!]);//按姓名查询void Prmt_MauiIiiterfaceQ^/主界面void Prmt_Iiiteiface_lQ;//职工信息录入界面void Prmt_Iiiteiface_2Qy/职工信息查询界面void Pimt_Iiiteiface_30-J!职工工资排序界面void Pimt_Iiiterfac e_4Q;//职工总工资void Prmt_Iiiterface_5()'J!文件读出void qsort(iiit Lint r);〃快速排序void Pimt_delete(iiit t);〃删除职工信息void Prmt_Iiiteiface_2_ 1 (iiit t);〃职工信息修改界面mt fvaiizheng(char sl[],char s2[]);//密码验证函数employee st[5OO]y/iB录职工信息的函数mt n;//职工总数void main()int x;employee em;pmitf(” @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@5”);pmitf(“ @@@@ 欢迎使用员工工资管理系统@@@@\n”);pmitf(” @@@@制作人:刘爽@@@@\n”);pmitf(“@@@@在使用中产生的任何问题,欢迎进行批评指正@@@@\n”);pnntf(” @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@5”);pnnrffg”);if (Print_jinru()){Fscaii_uifbiniation();Piint_ManiIiiteiiace();}else return;}void Fscan_infbmiation(){FILE *fp;int i;if ((fp=fopen (” 职工信息・txf JT”))==NULL){piiiitf(n caimot open tliis file\ii H);return;}fscanf(fp;*%d,\&n);for (i=l;i<=n;i++){fscanf(fp;,%s%s%d%s%d%d%d H,st[i].num,st[i].name,&st[i].age,st[i].sex,&st[i].salaiybasic, & st [i]. salary, subsidy,&st[i] .salary, wag 亡s);st[i].salaiy.sum=st[i].salaiybasic+st[i].salaiysubsidy+st[i].salary.wages;}fclose(fp);}mt fyaiizheng(char sl[],char s2[]){FILE *fpl,*fp2;chai- strl[40]=n,\str2[40]=,M\st;mt t;if((fpl=fbpenC< 号验证・in”,T))==NULL){prmtf(n caimot open tliis file\ii H); return 0;}t=0;st=fgetc(fpl);while (st!='#'){strl[t]=st;t++; st=fgetc(fpl);}if ((如2=fopen(”密码验证.in”,”F'))=NULL){piiiitf("caimot open this file\n"); return 0;}t=0;st=fgetc(fp2);while (st!='#'){str2[t]=st;t++; st=fgetc(fp2);}fclose(fpl);fclose(fp2);if ((strcmp(sti-1 ,s 1 )=0)&&(strcmp(str2,s2)==0)) return 1;elsereturn 0;}mt Print_jini-uQ{int f.d;chai- x[20],y[20];f=0;d=0;while(l)pnntf(”请输入账号J;scanf(”%s”,x);getcharQ;printf(”请输入密码:”);scaiif(M%s'\y);getcharQ;f=fyanzlieng(x,y);if(d>3){pnntf(”错误次数太多,退出系统\n”);return 0;}if (f>0) break;else{pnntf(”账号或密码输入错误,请重新输入\n”); d++;}}pmirf(” \n”);putf(”欢迎进入员工工资管理系统!帕“);retmn 1;} void Prmt_MauiIiiterfaceQ {int x;pnntfC,\n M);printf(M************** ***********pnntfC,\n M);piintf(" 1.职工信息录入\n"); pnntfC*2.职工信息查询\n”);pmitf(”3.职工工资排序\n”);pmitf(”4.统计职工总工资\n”); pmitf(“5.保存到文件\n”); pnntfC'6.退出职工工资系统5”);pnntf(-iW选择所需操作小);if (x=l)Piint_Iiitei-face_l (J;elseif (x=2)Piint_Iiitei-face_20;elsepnntf(” ****** printf(n * printf(n *pnntf(” ****** ********* * *” ****** **** * * * *; * * ** ***** ** if (x=3)Piint_Iiitei-face_30;elseif (x=4)Piint_Iiitei-face_40;elseif (x=5)Piint_Iiitei-face_50;elseif (x=6)pnntff233333333333333333333333333333333333333333333333333333\iT);return; } elsepnntf (”输入命令错误,返回主菜单(再乱输入我找人打你啊)\n”);Piint_ManiIiiteiiace ();void Prmt_Iiiterface_l()if(n>500)printfC 超出职工最大数\iT);Piint_ManiIiitei-face();printfp************** ***********pmitf (噺建职工号J');scanfC%s",st[n] .num); pmHff 姓名,);scanf(”%s",st[n]・nani 亡); pmHf(”年龄上); scanfC%d”,&st[n].age); pmitf (”性别:”); scanfC%s”,st[n]・sex); pmitf (”基本工资:”); scanfC%cT 、&st[n] .salary, basic); pmitf (”津贴:”); scanfC%cT 、&st[n] .salary, subsidy); pmitf (”奖金:”); scanf(,,%cl ,\&st[n] .salary, wages);st[n].salaiysum=st[n].salary.basic+st[n].salaiysubsidy+st[n].salary.wages; printf ("职工信息已成功录入\n"); Print_MauiIiitei-face();} void Prmt_Iiiterface_2() {int x;char s[5O],y[5O];pnntf(M\n M);pnntf(M\n M);pnntfC'l.查询所有职工\n”);pnntfC*2.按职工号查询\n”);pnntfC3.按职工姓名查询\n”);pmitf(”4.返回主菜单\n”); pnntfC-iW选择查找方式W);scanff%d';&x);if (x=l)Print_staff();if (x=2){ pnmf("请输入职工工号:”); scaiif(M%s,\y);Print_empll(y);}elseif (x=3){pruitfC1请输入职工姓名:”); scaiif(M%s'\s);Piint_empl2(s);} elseif (x=4)PiinCMaiiiIiitei-face();elsepnmf(”输入命令错误,返回上一层W);Piint_Iiitei-face_2Q;void Prmt_Iiiterface_3()char ch[10];pnntf(M\n M);qsort(l 卫);prmtf(”排序完成!排序后结果请从查询全体职工处查看5”);Print_MauiIiitei-face();void Prmt_Iiiterface_4()mt i,All=0;char ch[10];pnntf(M\n M);for (i=l;i<=n;i++)All=All+st[i].salary.sum;printf(“所有职工的总工资为:%d\n“, All);prmtf(”请输入任意字符并敲回车键返回主菜单\11”); scanf(H%s,\&ch);Print_MauiIiitei-face();void Prmt_Iiiterfac e_5 ()FILE *fp;char ch[10];inti;if ((fp=fopen (” 职工信息.txt,,/w n))=NULL)piiiitf(n caimot open tliis file\ii H); return;}for (i=l;i<=n;i++)fprmtf^fp/^s %s %d %s %d %d %d\n,\st[i].num,st[i].name,st[i].age,st[i].sex,st[i].salary.basic,st[i].salary.subsidy;st[i].salaiy.wages);fclose(fp);pmitffE);pnntf(”己保存到文件\n“);pgrf(”\n”);pnntf(-请输入任意字符返回主菜单\n”);scanf(H%s,\&ch);Print_Mauinitei-face();}”*************************帅比的分割线******************* ******”for (i=l;i<=n;i++){pnntf(” 职工工号:%s\n H,st[i].num); pnntf(” 姓名:%s\n'\st[i].name);printfC1年龄:%d\n H,st[i].age); 性别:%s\n H,st[i].sex);pnntf(” 基本工资:%d\n M,st[i].salary, basic); pnntf(” 津贴:%d\n'\st[i].salaiy subsidy); pnntf(” 奖金:%d\n'\st[i]. salaiy wages); printf{” 总工资:%d\n'\st[i].salary.sum); pnntf(%V);}pmitff返回上一层曲);Pnnt_Intei-face_2 Q;}void Priiit_empll(char x[]){int i,t,v,d=0:for (i=l;i<=n;i++)if (strcmp(x,st[i] .num)=0){t=l;d=l;pnntf(” 职工工号:%s\n”,st[i] .num);姓名:%s\ii",st[i].name);printfC 年龄:%d\ir\st[i].age);printfC 性别:%s\n H,st[i].sex); printff * 基本工资:%d\ii f\st[i].salary, basic); printf(” 津贴:%d\ir\st[i].salary.subsidy); printf(” 奖金:%d\n,\st[i].salary.wages); printf(” 总工资:%d\n",st[i]・salary.sum);pnntf(恤”);break;}if(d>0){printff如需删除请按2,修改请按1,返回请按0\n H); scanfC%d”,&y);疋(y==2)Priiit_delete(t);elseif(v==l)Priiit_Iiiteiiace_2_ 1 (t);elseif (y==o)Priiit_Iiiteiiace_2();else{pmitfC输入命令错误,返回上一层(再乱输入我找人打你啊)\n”);Priiit_Iiiteiiace_2();}}else{pnntfC对不起,查无此人(本系统不包括路人甲乙丙,不要乱输=!)\1T); 请重新选择查询方式\n”);Piiiit_Iiitei-fa c e_2 ();}}void Piiiit_empl2(chai- s[]){int igy=0;pmitffW);for (i=l;i<=n;i++)if (sticmp(s,st[i] .name)==0)t=i; y=i;pnntfC职工工号:%s\n”,st[i] .num);pimtf(n姓名:%s\n”、st[i].name);prmtf(H年龄:%d\n”,st[i]. age);prmtfC* 性别:%s\ii\st[i].sex);pnntfC 基本工资:%d\ir\st[i].salary basic);pdntfC 津贴:%d\n”,st[i]・salary.subsidy);prmtf(n奖金:%d\ir\st[i].salary.wages);pnntf(” 总工资:%d\n n,st[i].salary.sum);pnntfC\iT);break;}if (v>o){如需删除请按2,修改请按1,返回请按0(再乱输入我找人打你啊)\n”); scanf(”%d 雹&x);if (x==2)Pimt_delete(t);elseif (x==l)Pimt_Iiiteiface_2_l (t);elseif (x==0)Pimt_Iiiteiiace_2 ();else{prmtf(H输入命令错误,返回上一层\n”);Pi mt_Iiiteiiace_2();}}else{pnntfC对不起,查无此人(本系统不包括•路人甲乙丙,不要乱输=!)\iT); pimtf("请重新选择查询方式\n");Prmt_nitei-fac e_2 ();}}void Prmt_delete(mt t){st[t]. salary. sum=0;qsort(l 卫);ii 一;pnntf(”已删除该职工并排序,自动返回主菜单5”);Priiit_MauiIiitei-face();void Prmt_Iiiterface_2_l(mt t){int x;pnntf(H\n M);printf(”请选择以下选项:\n”);pnntf(M l.职工号\n“);pnntf(M2.姓名\n“);pmitf(”3.年龄\n”);pnntf(M4.性别\n“);printf(n 5 •基本工资\n”);pnntf(M6.津贴\n“);pnntf(M7.奖金\n”);pnntf("8.返回上一层\n”);pnntf("9.返回主菜单\n”);scanff%d 役&x);switch(x){case 1:scaiif(,,%s,\st[t].num);break;case 2:scaiif(,,%s,\st[t] .name);break;case 3:scaiif(,,%d,\st[t].age);bieak;case 4:scanf(ll%s,\st[t] .sex);break;case 5:scaiif(,,%s,\st[t].salaiybasic);bieak;case 6:scanf("%d,\st[t].salary.subsidy);break;case 7:scaiif(,,%d,\st[t].salaiywages);break:} st[t].salary.sum=st[t].salaiybasic+st[t].salary.subsidy+st[t].salary.wages; if(x<=8) Print_Iiitei-face_20;elseif (x=9)PiinCMaiiiIiitei-face();}void qsort(mt Lint r) int i,j,mid; employee tt;nud=st[(l+i)/2] .salary.sum;do{while (st[i].salary.sum>nud) i++; while (st[j].salary.sum<niid) j-;{st[i]=st[j];st[j]=tt;i++;J-S}}wlule(i<=j);if (i<r) qsort(i,r);if (l<j) qsort(lj);。

员工工资管理系统源代码

员工工资管理系统源代码

#include<stdio。

h>#include<string.h〉typedef struct{int basic;//基本工资int position;//岗位工资int subsidy;//津贴int wages;//奖金int sum;//总工资}money;typedef struct{char num[20];//职工号char name[20];//姓名int age;//年龄char sex[20];//性别money salary;//工资}employee;int Print_jinru();//账号密码输入void Fscan_information();//“职工信息。

txt”文件写入void Print_staff();//全体员工void Print_empl1(char x[51]);//按职工号查询void Print_empl2(char s[51]);//按姓名查询void Print_MainInterface();//主界面void Print_Interface_1();//职工信息录入界面void Print_Interface_2();//职工信息查询界面void Print_Interface_3();//职工工资排序界面void Print_Interface_4();//职工总工资void Print_Interface_5();//文件读出void qsort(int l,int r);//快速排序void Print_delete(int t);//删除职工信息void Print_Interface_2_1(int t);//职工信息修改界面int fyanzheng(char s1[],char s2[]);//密码验证函数employee st[500];//记录职工信息的函数int n;//职工总数void main(){int x;employee em;printf(”@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");printf("@@@@欢迎使用员工工资管理系统@@@@\n");printf(”@@@@制作人:刘爽@@@@\n");printf("@@@@在使用中产生的任何问题,欢迎进行批评指正@@@@\n");printf(”@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n”);printf(”\n”);printf(”\n");printf(”\n”);if (Print_jinru()){Fscan_information();Print_MainInterface();}else return;}void Fscan_information(){FILE *fp;int i;if ((fp=fopen(”职工信息。

C语言课程设计职工工资信息管理系统源代码

C语言课程设计职工工资信息管理系统源代码

#include <stdio.h>#include <string.h>#include <stdlib.h>#include <conio.h>#define N 10000int choice;struct employee{int num;int position;char name[10000];char sex[2];int salary;int i,max,t;}em[N];struct empsalary{char name[10000];int salary;}emps[N];void manage();void query();void input();void display();void change();void del();void add();void paixu();int changeposition();int changesalary();void querysalary();void creat();void main(){do{printf("欢迎进入职工管理系统中文版\n"); printf("请你选择操作类型:\n");printf("1进入管理系统\n");printf("2进入查询系统\n");printf("0退出系统\n");scanf("%d",&choice);switch(choice){case 1:manage();break;case 2:query();break;case 0:{printf("谢谢使用,再见\n");exit(0);}default:{printf("输入有错误请重新输入:\n");return;}}}while(1);}void manage(){int choicemanage;char choice='y';while(choice=='y'||choice=='Y'){printf("欢迎进入管理系统\n");printf("请你选择操作类型:\n");printf("1输入职工信息\n");printf("2显示职工信息\n");printf("3修改职工信息\n");printf("4追加一个职工信息\n");printf("5删除一个职工信息\n");printf("6排序\n");printf("0返回\n");scanf("%d",&choicemanage);switch(choicemanage){case 1:input();break;case 2:display();break;case 3:change();break;case 4:add();break;case 5:del();case 6:paixu();break;case 0:printf("谢谢你的使用再见\n");return;default:printf("你的输入有错请重新输入\n"); }printf("是否继续管理?(y/n)");scanf("%s",&choice);}if(toupper(choice)=='N'||(choice)=='n'){printf("输入完毕,任意键返回\n");getch();return;}}void input(){FILE *fp;int i=0;char choiceinput='y';if((fp=fopen("employee.txt","w"))==NULL) return;while(choiceinput=='y'||choiceinput=='Y'){i++;printf("第%d个职工\n",i);printf("\n");printf("请你输入工号:\n");scanf("%d",&em[i].num);printf("\n");printf("请你输入职位:\n");printf("1董事长2总经理3副总经理\n");printf("4经理5副经理6秘书\n");printf("7技术员8领班9员工\n");scanf("%d",&em[i].position);printf("\n");printf("请你输入姓名:\n");scanf("%s",em[i].name);printf("\n");printf("请你输入性别以m为男f为女:\n");scanf("%s",em[i].sex);printf("\n");printf("请你输入工资:\n");scanf("%d",&em[i].salary);printf("\n");printf("是否继续输入?(y/n)\n");scanf("%s",&choiceinput);fwrite(&em[i],sizeof(struct employee),1,fp);}if(toupper(choiceinput)=='N'){fclose(fp);printf("输入完毕,任意键返回\n");getch();return;}}void display(){FILE *fp;int i;if((fp=fopen("employee.txt","r"))==NULL)return;printf("输出结果:\n");for(i=0;fread(&em[i],sizeof(struct employee),1,fp)!=0;i++) {printf("工号%d\n",em[i].num);printf("职位为%d\n",em[i].position);printf("1董事长2总经理3副总经理\n");printf("4经理5副经理6秘书\n");printf("7技术员8领班9员工\n");printf("姓名为%s\n",em[i].name);printf("性别为%s\n",em[i].sex);printf("其中m为男f为女\n");printf("工资为%d\n",em[i].salary);}printf("完毕按任意键返回\n");getch();fclose(fp);return;}void change(){FILE *fp;int i;char chname[8];int choicechange;printf("请你输入要修改的人的姓名:\n");scanf("%s",&chname);if((fp=fopen("employee.txt","w+"))==NULL){printf("不能够打开这个文件\n");return;}for(i=0;i<N;i++){if(strcmp(chname,em[i].name)==0){printf("这是你要修改的人的信息\n");printf("工号为%d\n 职位为%d\n 姓名为%s\n 性别为%s\n 工资为%d\n",em[i].num,em[i].position,em[i].name,em[i].sex,em[i].salary);printf("请你输入要修改的部分:\n");printf("1修改职位\n");printf("2修改工资\n");printf("0退出系统\n");printf("请选择\n");scanf("%d",&choicechange);switch(choicechange){case 1:em[i].position=changeposition();break;case 2:em[i].salary=changesalary();break;case 0:return;default :printf("输入有错误");}fwrite(&em[i],sizeof(struct employee),1,fp); }}fclose(fp);printf("操作完成按任意键返回\n");getch();return;}int changeposition(){int newposition;printf("请你输入新职位:\n");printf("1董事长2总经理3副总经理\n"); printf("4经理5副经理6秘书\n"); printf("7技术员8领班9员工\n"); scanf("%d",&newposition);return(newposition);}int changesalary(){int newsalary;printf("请你输入新的工资:\n");scanf("%d",&newsalary);return(newsalary);}void add(){struct employee emp;FILE *fp;int i=0;if((fp=fopen("employee.txt","ab+"))==NULL){printf("不能够打开这个文件\n");getch();return;}printf("请你输入新人的内容:\n");printf("请你输入工号:\n");scanf("%d",&em[i].num);printf("请你输入职位:\n");printf("1董事长2总经理3副总经理\n");printf("4经理5副经理6秘书\n");printf("7技术员8领班9员工\n");scanf("%d",&emp.position);printf("请你输入姓名:\n");scanf("%s",);printf("请你输入性别以m为男f为女:\n");scanf("%s",emp.sex);printf("请你输入工资:\n");scanf("%d",&emp.salary);fwrite(&emp,sizeof(struct employee),1,fp);rewind(fp);printf("插入完毕,按任意键返回\n");getch();fclose(fp);return;}void del(){int i=0;char delname[8];FILE *fp;if((fp=fopen("employee.txt","w"))==NULL){printf("文件为空,不能够打开\n");printf("按任意键返回\n");getch();return;}printf("请你输入要删除的人的姓名:\n");scanf("%s",delname);for(i=0;fread(&em[i],sizeof(struct employee),1,fp)!=0;i++) {if(strcmp(em[i].name,delname)!=0)fwrite(&em[i],sizeof(struct employee),1,fp);}fclose(fp);if((fp=fopen("employee.txt","r"))==NULL)return;printf("新的职工的信息为:\n");for(i=0;fread(&em[i],sizeof(struct employee),1,fp)!=0;i++) {printf("工号%d",em[i].num);printf("职位为%d",em[i].position);printf("1董事长2总经理3副总经理\n");printf("4经理5副经理6秘书\n");printf("7技术员8领班9员工\n");printf("姓名为%s\n",em[i].name[8]);printf("性别为%s\n",em[i].sex[2]);printf("其中m为男f为女\n");printf("工资为%d\n",em[i].salary);fclose(fp);}}void query(){FILE *fp;int i=0;char quename[8];if((fp=fopen("employee.txt","r"))==NULL){printf("不能够打开文件,按任意键返回\n");getch();return;}printf("请你输入要查询的人的姓名\n");scanf("%s",quename);for(i=0;fread(&em[i],sizeof(struct employee),1,fp)!=0;i++) {if(strcmp(em[i].name,quename)==0){printf("\t\t\n查询到的职工号或姓名为的信息如下:\n");printf("以下是你要查询的人的信息\n");printf("工号%d",em[i].num);printf("职位为%d",em[i].position);printf("\t 1董事长2总经理3副总经理\n");printf("\t 4经理5副经理6秘书\n");printf("\t 7技术员8领班9员工\n");printf("姓名为%s\n",em[i].name);printf("性别为%s\n",em[i].sex);printf("\t其中m为男f为女\n");printf("工资为%d\n",em[i].salary);printf("\n");printf("查询完毕,按任意键返回\n");getch();fclose(fp);return;}}printf("没有这样的人,按任意键返回\n");getch();fclose(fp);return;}void querysalary(){int i;FILE *fp1,*fp2;creat();if((fp1=fopen("employee.txt","w+"))==NULL)return;for(i=0;fread(&em[i],sizeof(struct employee),1,fp1)!=0;i++) {printf("输出结果为:\n");printf("工号%d",em[i].num);printf("职位为%d",em[i].position);printf(" 1董事长2总经理3副总经理\n");printf(" 4经理5副经理6秘书\n");printf(" 7技术员8领班9员工\n");printf("姓名为%s\n",em[i].name[8]);printf("性别为%s\n",em[i].sex[2]);printf("其中m为男f为女\n");printf("工资为%d\n",em[i].salary);strcpy(emps[i].name,em[i].name);emps[i].salary=em[i].salary;}if((fp2=fopen("empsalary.txt","w"))==NULL)return;for(i=0;i<N;i++)fwrite(&emps[i],sizeof(struct empsalary),1,fp2);fclose(fp1);fclose(fp2);}void creat(){FILE *fp;if((fp=fopen("D:\\employee.txt","w+"))==NULL)return;input();fclose(fp);}void paixu(){int max,i,t,j;for(i=1;i<10;i++){max=em[i].salary;for(j=i;j<10;j++){if(em[j].salary>max){max=em[j].salary;t=em[j].salary;em[j].salary=t;}}}printf("姓名工资工号性别职位\n");for(i=1;i<10;i++)printf(" %s %d %d %s %d\n ",em[i].name,em[i].salary,em[i].num,em[i].sex,em[i].position);}。

员工工资管理系统源代码

员工工资管理系统源代码

#include<stdio。

h〉#include〈string。

h>typedef struct{int basic;//基本工资int position;//岗位工资int subsidy;//津贴int wages;//奖金int sum;//总工资}money;typedef struct{char num[20];//职工号char name[20];//姓名int age;//年龄char sex[20];//性别money salary;//工资}employee;int Print_jinru();//账号密码输入void Fscan_information();//“职工信息。

txt”文件写入void Print_staff();//全体员工void Print_empl1(char x[51]);//按职工号查询void Print_empl2(char s[51]);//按姓名查询void Print_MainInterface();//主界面void Print_Interface_1();//职工信息录入界面void Print_Interface_2();//职工信息查询界面void Print_Interface_3();//职工工资排序界面void Print_Interface_4();//职工总工资void Print_Interface_5();//文件读出void qsort(int l,int r);//快速排序void Print_delete(int t);//删除职工信息void Print_Interface_2_1(int t);//职工信息修改界面int fyanzheng(char s1[],char s2[]);//密码验证函数employee st[500];//记录职工信息的函数int n;//职工总数void main(){int x;employee em;printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n”);printf("@@@@欢迎使用员工工资管理系统@@@@\n");printf("@@@@ 制作人:刘爽@@@@\n”);printf(”@@@@在使用中产生的任何问题,欢迎进行批评指正@@@@\n”);printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n");printf("\n");printf(”\n”);printf("\n”);if (Print_jinru()){Fscan_information();Print_MainInterface();}else return;}void Fscan_information(){FILE *fp;int i;if ((fp=fopen("职工信息。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

#include<stdio.h>#include<string.h>typedef struct{int basic;//基本工资int position;//岗位工资int subsidy;//津贴int wages;//奖金int sum;//总工资}money;typedef struct{char num[20];//职工号char name[20];//姓名int age;//年龄char sex[20];//性别money salary;//工资}employee;int Print_jinru();//账号密码输入void Fscan_information();//“职工信息.txt”文件写入void Print_staff();//全体员工void Print_empl1(char x[51]);//按职工号查询void Print_empl2(char s[51]);//按姓名查询void Print_MainInterface();//主界面void Print_Interface_1();//职工信息录入界面void Print_Interface_2();//职工信息查询界面void Print_Interface_3();//职工工资排序界面void Print_Interface_4();//职工总工资void Print_Interface_5();//文件读出void qsort(int l,int r);//快速排序void Print_delete(int t);//删除职工信息void Print_Interface_2_1(int t);//职工信息修改界面int fyanzheng(char s1[],char s2[]);//密码验证函数employee st[500];//记录职工信息的函数int n;//职工总数void main(){int x;employee em;printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@\n");printf("@@@@ 欢迎使用员工工资管理系统@@@@\n");printf("@@@@ 制作人:刘爽@@@@\n");printf("@@@@在使用中产生的任何问题,欢迎进行批评指正@@@@\n");printf("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@@\n");printf("\n");printf("\n");printf("\n");if (Print_jinru()){Fscan_information();Print_MainInterface();}else return;}void Fscan_information(){FILE *fp;int i;if ((fp=fopen("职工信息.txt","r"))==NULL){printf("cannot open this file\n");return ;}fscanf(fp,"%d",&n);for (i=1;i<=n;i++){fscanf(fp,"%s%s%d%s%d%d%d",st[i].num,st[i].name,&st[i].age,st[i].sex,&st[i].salary.basic,&s t[i].salary.subsidy,&st[i].salary.wages);st[i].salary.sum=st[i].salary.basic+st[i].salary.subsidy+st[i].salary.wages;}fclose(fp);}int fyanzheng(char s1[],char s2[]){FILE *fp1,*fp2;char str1[40]="",str2[40]="",st;int t;if ((fp1=fopen("账号验证.in","r"))==NULL){printf("cannot open this file\n");return 0;}t=0;st=fgetc(fp1);while (st!='#'){str1[t]=st;t++;st=fgetc(fp1);}if ((fp2=fopen("密码验证.in","r"))==NULL){printf("cannot open this file\n");return 0;}t=0;st=fgetc(fp2);while (st!='#'){str2[t]=st;t++;st=fgetc(fp2);}fclose(fp1);fclose(fp2);if ((strcmp(str1,s1)==0)&&(strcmp(str2,s2)==0)) return 1;elsereturn 0;}int Print_jinru(){int f,d;char x[20],y[20];f=0;d=0;while(1){printf("请输入账号:");scanf("%s",x);getchar();printf("请输入密码:");scanf("%s",y);getchar();f=fyanzheng(x,y);if (d>3)printf("错误次数太多,退出系统\n");return 0;}if (f>0) break;else{printf("账号或密码输入错误,请重新输入\n");d++;}}printf("\n");printf("欢迎进入员工工资管理系统\n");return 1;}void Print_MainInterface(){int x;printf("\n");printf("*************************华丽的分割线*************************\n");printf("\n");printf("1.职工信息录入\n");printf("2.职工信息查询\n");printf("3.职工工资排序\n");printf("4.统计职工总工资\n");printf("5.保存到文件\n");printf("6.退出职工工资系统\n");printf("请选择所需操作:");scanf("%d",&x);if (x==1)Print_Interface_1();elseif (x==2)Print_Interface_2();elseif (x==3)Print_Interface_3();elseif (x==4)Print_Interface_4();elseif (x==5)Print_Interface_5();else{printf(" ****** **** **** * * ***** * *\n");printf("* * * * * * * * * * *\n");printf("* * * * * * * * * * *\n");printf(" ****** ******** ******** ** * * * *\n");printf(" * * * ** * * * *\n");printf(" * * * ** * * * *\n");printf(" ****** **** **** ** ***** ***** \n");//printf("233333333333333333333333333333333333333333333333333333\n");return;}else{printf("输入命令错误,返回主菜单(再乱输入我找人打你啊)\n");Print_MainInterface();}}void Print_Interface_1(){n++;if (n>500){printf("超出职工最大数\n");Print_MainInterface();}printf("\n");printf("*************************妖精的分割线*************************\n");printf("\n");printf("新建职工号:");scanf("%s",st[n].num);printf("姓名:");scanf("%s",st[n].name);printf("年龄:");scanf("%d",&st[n].age);printf("性别:");scanf("%s",st[n].sex);printf("基本工资:");scanf("%d",&st[n].salary.basic);printf("津贴:");scanf("%d",&st[n].salary.subsidy);printf("奖金:");scanf("%d",&st[n].salary.wages);st[n].salary.sum=st[n].salary.basic+st[n].salary.subsidy+st[n].salary.wages;printf("职工信息已成功录入\n");Print_MainInterface();}void Print_Interface_2(){int x;char s[50],y[50];printf("\n");printf("*************************逗比的分割线*************************\n");printf("\n");printf("1.查询所有职工\n");printf("2.按职工号查询\n");printf("3.按职工姓名查询\n");printf("4.返回主菜单\n");printf("请选择查找方式:\n");scanf("%d",&x);if (x==1)Print_staff();elseif (x==2){printf("请输入职工工号:");scanf("%s",y);Print_empl1(y);}elseif (x==3){printf("请输入职工姓名:");scanf("%s",s);Print_empl2(s);}elseif (x==4)Print_MainInterface();else{printf("输入命令错误,返回上一层\n");Print_Interface_2();}}void Print_Interface_3(){char ch[10];printf("\n");qsort(1,n);printf("排序完成!排序后结果请从查询全体职工处查看\n");Print_MainInterface();}void Print_Interface_4(){int i,All=0;char ch[10];printf("\n");for (i=1;i<=n;i++)All=All+st[i].salary.sum;printf("所有职工的总工资为:%d\n",All);printf("请输入任意字符并敲回车键返回主菜单\n");scanf("%s",&ch);Print_MainInterface();}void Print_Interface_5(){FILE *fp;char ch[10];int i;if ((fp=fopen("职工信息.txt","w"))==NULL){printf("cannot open this file\n");return ;}fprintf(fp,"%d\n",n);for (i=1;i<=n;i++)fprintf(fp,"%s %s %d %s %d %d %d\n",st[i].num,st[i].name,st[i].age,st[i].sex,st[i].salary.basic, st[i].salary.subsidy,st[i].salary.wages);fclose(fp);printf("\n");printf("已保存到文件\n");printf("\n");printf("请输入任意字符返回主菜单\n");scanf("%s",&ch);Print_MainInterface();}void Print_staff(){int i;printf("\n");printf("*************************帅比的分割线*************************");printf("\n");for (i=1;i<=n;i++){printf("职工工号:%s\n",st[i].num);printf("姓名:%s\n",st[i].name);printf("年龄:%d\n",st[i].age);printf("性别:%s\n",st[i].sex);printf("基本工资:%d\n",st[i].salary.basic);printf("津贴:%d\n",st[i].salary.subsidy);printf("奖金:%d\n",st[i].salary.wages);printf("总工资:%d\n",st[i].salary.sum);printf("\n");}printf("返回上一层\n");Print_Interface_2();}void Print_empl1(char x[]){int i,t,y,d=0;printf("\n");for (i=1;i<=n;i++)if (strcmp(x,st[i].num)==0){t=i;d=1;printf("职工工号:%s\n",st[i].num);printf("姓名:%s\n",st[i].name);printf("年龄:%d\n",st[i].age);printf("性别:%s\n",st[i].sex);printf("基本工资:%d\n",st[i].salary.basic);printf("津贴:%d\n",st[i].salary.subsidy);printf("奖金:%d\n",st[i].salary.wages);printf("总工资:%d\n",st[i].salary.sum);printf("\n");break;}if (d>0){printf("如需删除请按2,修改请按1,返回请按0\n");scanf("%d",&y);if (y==2)Print_delete(t);elseif (y==1)Print_Interface_2_1(t);elseif (y==0)Print_Interface_2();else{printf("输入命令错误,返回上一层(再乱输入我找人打你啊)\n");Print_Interface_2();}}else{printf("对不起,查无此人(本系统不包括路人甲乙丙,不要乱输-_-!)\n");printf("请重新选择查询方式\n");Print_Interface_2();}}void Print_empl2(char s[]){int i,t,x,y=0;printf("\n");for (i=1;i<=n;i++)if (strcmp(s,st[i].name)==0){t=i;y=1;printf("职工工号:%s\n",st[i].num);printf("姓名:%s\n",st[i].name);printf("年龄:%d\n",st[i].age);printf("性别:%s\n",st[i].sex);printf("基本工资:%d\n",st[i].salary.basic);printf("津贴:%d\n",st[i].salary.subsidy);printf("奖金:%d\n",st[i].salary.wages);printf("总工资:%d\n",st[i].salary.sum);printf("\n");break;}if (y>0){printf("如需删除请按2,修改请按1,返回请按0(再乱输入我找人打你啊)\n");scanf("%d",&x);if (x==2)Print_delete(t);elseif (x==1)Print_Interface_2_1(t);elseif (x==0)Print_Interface_2();else{printf("输入命令错误,返回上一层\n");Print_Interface_2();}}else{printf("对不起,查无此人(本系统不包括路人甲乙丙,不要乱输-_-!)\n");printf("请重新选择查询方式\n");Print_Interface_2();}}void Print_delete(int t){st[t].salary.sum=0;qsort(1,n);n--;printf("已删除该职工并排序,自动返回主菜单\n");Print_MainInterface();}void Print_Interface_2_1(int t){int x;printf("\n");printf("请选择以下选项:\n");printf("1.职工号\n");printf("2.姓名\n");printf("3.年龄\n");printf("4.性别\n");printf("5.基本工资\n");printf("6.津贴\n");printf("7.奖金\n");printf("8.返回上一层\n");printf("9.返回主菜单\n");scanf("%d",&x);switch(x){case 1:scanf("%s",st[t].num);break;case 2:scanf("%s",st[t].name);break;case 3:scanf("%d",st[t].age);break;case 4:scanf("%s",st[t].sex);break;case 5:scanf("%s",st[t].salary.basic);break;case 6:scanf("%d",st[t].salary.subsidy);break;case 7:scanf("%d",st[t].salary.wages);break;}st[t].salary.sum=st[t].salary.basic+st[t].salary.subsidy+st[t].salary.wages;if (x<=8)Print_Interface_2();elseif (x==9)Print_MainInterface();}void qsort(int l,int r){int i,j,mid;employee tt;i=l;j=r;mid=st[(l+r)/2].salary.sum;do{while (st[i].salary.sum>mid) i++;while (st[j].salary.sum<mid) j--;if (i<=j){tt=st[i];st[i]=st[j];st[j]=tt;i++;j--;}}while(i<=j);if (i<r) qsort(i,r);if (l<j) qsort(l,j);。

相关文档
最新文档