工资管理系统源代码

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

#includestdio.h#includestring.h#includectype.h#includestdlib.h#includewindows.h#defineMONTH_NUM5/*最多的月份*/structworker{intnumber;/*每个工人的工号*/charname[15];/*每个工人的姓名*/intsalary[MONTH_NUM];/*每个工人M月的工资*/intsum;/*每个工人的总工资*/floataverage;/*每个工人的平均工资*/structworker*next;//下一个节点的地址};typedefstructworkerSTU;charMenu(void);intAscending(inta,intb);intDescending(inta,intb);voidIntSwap(int*pt1,int*pt2);voidCharSwap(char*pt1,char*pt2);voidFloatSwap(float*pt1,float*pt2);STU*AppendNode(STU*head,constintm);STU*DeleteNode(STU*head,intnodeNum);STU*ModifyNode(STU*head,intnodeNum,constintm);STU*SearchNode(STU*head,intnodeNum);STU*Appendsalary(STU*head,constintm);voidTotalsalary(STU*head,constintm);voidPrintsalary(STU*head,constintm);STU*Deletesalary(STU*head,constintm);voidModifysalary(STU*head,constintm);voidSortsalary(STU*head,constintm,int(*compare)(inta,intb));voidSearchsalary(STU*head,constintm);voidDeleteMemory(STU*head);voidnumberSwap(STU*head);main(){charch,b;intm,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≈~☆输入要记录的月份个数(m10)☆~~`≈:);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(\nAftermodified\n);Printsalary(head,m);Sleep(1000);break;case'3':head=Deletesalary(head,m);printf(\nAfterdeleted\n);Printsalary(head,m);break;case'4':do{Searchsalary(head,m);printf(\(≧▽≦)/是否要继续查询?YorN:);scanf(%c,&b);}while(b=='y'||b=='Y');break;case'5':Printsalary(head,m);printf(\(≧▽≦)/是否要选择排列方式?YorN:);scanf(%c,&b);while(b=='y'||b=='Y'){printf(你想降序排列还是升序排列?(1降序2升序):);scanf(%d,&a);if(a==1){Sortsalary(head,m,Descending);printf(\nsortedindescendingorderbysum\n);Printsalary(head,m);}else{Sortsalary(head,m,Ascending);printf(\nsortedinascendingorderbysum\n);Printsalary(head,m);}printf(O(∩_∩)O是否继续选择排列方式?YorN:);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(Endofprogram!);break;default:printf(Inputerror!);break;}}}charMenu(void)//主菜单{charch;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);returnch;}STU*Appendsalary(STU*head,constintm)//添加新记录{inti=0;charc;do{head=AppendNode(head,m);/*向链表末尾添加一个节点*/printf(\nO(∩_∩)O你想再添加一个新的记录吗(Y/N)?);scanf(%c,&c);/*%c前面有一个空格*/i++;}while(c=='Y'||c=='y');printf(%dnewnodeshavebeenapended!\n,i);returnhead;}STU*Deletesalary(STU*head,constintm)//删除记录{inti=0,nodeNum;charc;do{printf(\n⊙﹏⊙请输入你想删除的记录编号:);scanf(%d,&nodeNum);head=DeleteNode(head,nodeNum);/*删除工号为nodeNum的工人信息*/Printsalary(head,m);/*显示当前链表中的各节点信息*/printf(Doyouwanttodeleteanode(Y/N)?);scanf(%c,&c);/*%c前面有一个空格*/i++;}while(c=='Y'||c=='y');printf(%dnodeshavebeendeleted!\n,i);returnhead;}voidModifysalary(STU*head,constintm)//修改记录{inti=0,nodeNum;charc;do{printf(\n~~~^_^~~~请输入你想修改的记录编号:);scanf(%d,&nodeNum);head=ModifyNode(head,nodeNum,m);/*修改工号为nodeNum的节点*/printf(Doyouwanttomodifyanode(Y/N)?);scanf(%c,&c);/*%c前面有一个空格*/i++;}while(c=='Y'||c=='y');printf(%dnodeshavebeenmodified!\n,i);}voidTotalsalary(STU*head,constintm){STU*p=head;inti;while(p!=NULL)/*若不是表尾,则循环*/{p-sum=0;for(i=0;im;i++){p-sum+=p-salary[i];}p-average=(float)p-sum/m;p=p-next;/*让p指向下一个节点*/}}voidSortsalary(STU*head,constintm,int(*compare)(inta,intb)){STU*pt;intflag=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;im;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);}/*交换两个整型数*/voidIntSwap(int*pt1,int*pt2){inttemp;temp=*pt1;*pt1=*pt2;*pt2=temp;}/*交换两个实型数*/voidFloatSwap(float*pt1,float*pt2){floattemp;temp=*pt1;*pt1=*pt2;*pt2=temp;}/*交换两个字符串*/voidCharSwap(char*pt1,char*pt2){chartemp[15];strcpy(temp,pt1);strcpy(pt1,pt2);strcpy(pt2,temp);}/*决定数据是否按升序排序,ab为真,则按升序排序*/intAscending(inta,intb){returnab;}/*决定数据是否按降序排序,ab为真,则按降序排序*/intDescending(inta,intb

1 / 17
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功