高校工资管理系统设计源代码
- 格式:docx
- 大小:26.88 KB
- 文档页数:12
课程设计教师工资管理系统运行平台:VC6.0〔其他平台未经测试,不一定保证有效〕制弓箭中南大学信息科学与工程学院源代码如下:*include <stdio.h>*include <stdlib.h>*include <string.h>*include <conio.h>*define LEN sizeof(struct teacher)struct teacher{int num;char name[20];char sex[20];char workplace[50];char address[50];long phone;double de_salary;double de_jintie;double de_shenghuobutie;double yingfa_salary;double cost_phone;double cost_water_elec;double cost_rent;double cost_tax;double cost_weisheng;double cost_gongjijin;double cost_all;double shifa_salary;struct teacher *next;};/***********************************读取函数************************************/struct teacher *load(){struct teacher *p1,*p2,*head;FILE *fp;int i=1;if((fp=fopen("save","rb"))==NULL){printf(" 文件不存在!按下任意键返回主菜单...");getch();return (NULL);}else{head=NULL;p1=(struct teacher *)malloc(LEN);while (fread(p1,LEN-4,1,fp)==1){if(i==1){head=p1;p2=p1;i=2;}else{p2->next=p1;p2=p2->next;}p1=(struct teacher *)malloc(LEN);}p2->next=NULL;free(p1);fclose(fp);return(head);}}/**********************************欢送菜单函数*************************************/void wele(){printf("\n\n\n >>>>>欢送使用教师工资管理系统Beta1.2<<<<<\n");printf(" *******************************************************\n");printf(" * C语言课程设计教师工资管理系统*\n");printf(" * 班级:电气信息类1001班学号:0909100119 *\n");printf(" * XX:弓箭*\n");printf(" *******************************************************\n");printf("\n\n 按下任意键进入系统...");getch();system("cls");}/**********************************制作人员*************************************/void list(){system("cls");printf("\n\n\n >>>>>所有侵权必究<<<<<\n");printf("*******************************************************************************\n");printf("* 学校(College): 中南大学Central South University *\n");printf("* 软件名称(Software):教师工资管理系统Teacher's Salary Managing System *\n");printf("* 版本号(Edition): Beta1.2 *\n");printf("* 制作人(Producer):弓箭James *\n");printf("* 所在班级(Class):电气信息类1001班Electric Information 1001 *\n");printf("* 所在学院(Institute):信息科学与工程学院Information Engineering Institute*\n");printf("*******************************************************************************\n");printf(" >>>>>ILLEGAL COPY BANNED<<<<<\n");printf("\n\n 按下任意键返回主菜单...");getch();}/***********************************菜单函数*****************************************/int menu(){int i;printf("\n\n\n >>>>>欢送使用教师工资管理系统Beta1.2<<<<<\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(" *******************************************************\n");printf(" 请输入你想要的操作:");scanf("%d",&i);getchar();return i;}/***********************************插入函数*****************************************/void input(){struct teacher *head,*p1,*p2,*p3,*px;int i,t;FILE *fp;char k,n='n',num[30],name[20];p1=p2=p3=px=(struct teacher *)malloc(LEN);if((head=load())!=NULL){do{n='n';printf(" 请输入要插入的教师信息:\n");printf(" ------------------------------\n");printf(" 请输入教工号:");gets(num);px->num=atoi(num);printf(" 请输入XX:");gets(px->name);printf(" 请输入性别:");gets(px->sex);printf(" 请输入单位名称:");gets(px->workplace);printf(" 请输入家庭住址:");gets(px->address);printf(" 请输入联系:");gets(num);px->phone=atoi(num);printf(" 请输入根本工资:");gets(num);px->de_salary=atof(num);printf(" 请输入津贴:");gets(num);px->de_jintie=atof(num);printf(" 请输入生活补贴:");gets(num);px->de_shenghuobutie=atof(num);printf(" 请输入费:");gets(num);px->cost_phone=atof(num);printf(" 请输入水电费:");gets(num);px->cost_water_elec=atof(num);printf(" 请输入房租:");gets(num);px->cost_rent=atof(num);printf(" 请输入个人所得税:");gets(num);px->cost_tax=atof(num);printf(" 请输入卫生费:");gets(num);px->cost_weisheng=atof(num);printf(" 请输入公积金:");gets(num);px->cost_gongjijin=atof(num);px->yingfa_salary=px->de_salary+px->de_jintie+px->de_shenghuobutie;px->cost_all=px->cost_phone+px->cost_water_elec+px->cost_rent+px->cost_tax+px->cost_weisheng+px->cost_g ongjijin;px->shifa_salary=px->yingfa_salary-px->cost_all;printf(" 数据输入完毕,按下任意键继续...");getch();system("cls");printf("\n\n\n >>>>>>>>>>> 插入教师信息<<<<<<<<<<<\n");printf(" *******************************************************\n");printf(" * 1.输入教师号*\n");printf(" * 2.输入XX *\n");printf(" * 3.返回上级菜单*\n");printf(" *******************************************************\n");printf(" 请选择插入式:");scanf("%d",&i);getchar();while (i<1||i>3){printf(" 输入有误!请重新输入:");scanf("%d",&i);getchar();}switch(i){case 1:printf(" 请输入要插入在哪条数据后面:");scanf("%d",&t);getchar();p1=head;while (p1->num!=t){if (p1->next!=NULL){ p1=p1->next;}else{printf(" 查找不到相关数据!\n");break;}}if (p1->num==t){printf("-----------------------------要插入的信息如下:--------------------------------\n");printf("教工号XX 性别单位名称家庭住址联系\n");printf(" %-4d %-13s %s %-19s %-19s%-14ld\n",px->num,px->name,px->sex,px->workplace,px->address,px->phone);printf("费水电费房租个人所得税卫生费公积金合计扣款\n");printf(" %-10.1lf %-10.1lf %-10.1lf %-10.1lf %-10.1lf %-10.1lf %-10.1lf\n",px->cost_phone,px->cost_water_elec,px ->cost_rent,px->cost_tax,px->cost_weisheng,px->cost_gongjijin,px->cost_all);printf("根本工资津贴生活补贴应发工资实发工资\n");printf(" %-13.1lf %-13.1lf %-13.1lf %-13.1lf %-13.1lf\n",px->de_salary,px->de_jintie,px->de_shenghuobutie,px->yin gfa_salary,px->shifa_salary);printf("-------------------------------------------------------------------------------\n");printf(" 确定插入吗.〔y或n〕:");scanf("%c",&k);getchar();}if (k=='y'||k=='Y'){if (p1->num==t){if(p1==head)/*如果插入点为头指针*/{p3=p1->next;p1->next=px;px->next=p3;p2=head;}else if(p1->next==NULL)/*如果插入点为末尾指针*/{p3=p1;p1=head;p2=head;while(p1->next!=p3){p1=p1->next;}p1=p1->next;p1->next=px;px->next=NULL;}else{/*如果插入点为中间指针*/p3=p1;p1=head;p2=head;while(p1->next!=p3){p1=p1->next;}p1=p1->next;p3=p1->next;px->next=p3;p1->next=px;}if((fp=fopen("save","wb"))==NULL){printf(" 文件不存在!按下任意键返回主菜单...");getch();}else{do{fwrite(p2,LEN-4,1,fp);if(p2->next!=NULL)p2=p2->next;}while(p2->next!=NULL);if(p2!=head)fwrite(p2,LEN-4,1,fp);}fclose(fp);printf(" 插入成功!按下任意键继续...");getch();}}else {printf(" 插入已被取消!按下任意键继续...");getch();}break;case 2:printf(" 请输入要插入的教师XX:");gets(name);p1=head;while (strcmp((p1->name),name)!=0){if (p1->next!=NULL)p1=p1->next;else{printf(" 查找不到相关数据!\n");break;}}if (strcmp((p1->name),name)==0){printf("-----------------------------要插入的信息如下:--------------------------------\n");printf("教工号XX 性别单位名称家庭住址联系\n");printf(" %-4d %-13s %s %-19s %-19s%-14ld\n",p1->num,p1->name,p1->sex,p1->workplace,p1->address,p1->phone);printf("费水电费房租个人所得税卫生费公积金合计扣款\n");printf(" %-10.1lf %-10.1lf %-10.1lf %-10.1lf %-10.1lf %-10.1lf %-10.1lf \n",p1->cost_phone,p1->cost_water_elec,p1->cost_rent,p1->cost_tax,p1->cost_weisheng,p1->cost_gongjijin,p1->cost_all);printf("根本工资津贴生活补贴应发工资实发工资\n");printf(" %-13.1lf %-13.1lf %-13.1lf %-13.1lf %-13.1lf\n",p1->de_salary,p1->de_jintie,p1->de_shenghuobutie,p1->yin gfa_salary,p1->shifa_salary);printf("-------------------------------------------------------------------------------\n");printf(" 确定插入吗.〔y或n〕:");scanf("%c",&k);getchar();}if (k=='y'||k=='Y'){if (strcmp((p1->name),name)==0){if(p1==head)/*如果插入点为头指针*/{p1->next=px;p2=head;}else if(p1->next==NULL)/*如果插入点为末尾指针*/{p3=p1;p1=head;p2=head;while(p1->next!=p3){p1=p1->next;}p1=p1->next;p1->next=px;px->next=NULL;}else{/*如果插入点为中间指针*/p3=p1;p1=head;p2=head;while(p1->next!=p3){p1=p1->next;}p1=p1->next;p1->next=px;p3=p3->next;px->next=p3;}if((fp=fopen("save","wb"))==NULL){printf(" 文件不存在!按下任意键返回主菜单...");getch();}else{do{fwrite(p2,LEN-4,1,fp);if(p2->next!=NULL)p2=p2->next;}while(p2->next!=NULL);if(p2!=head)fwrite(p2,LEN-4,1,fp);}fclose(fp);printf(" 插入成功!按下任意键继续...");getch();}}else {printf(" 插入已被取消!按下任意键继续...");getch();}break;case 3:break;default :break;}if (i!=3){printf("\n 继续插入其他教师的信息吗.〔y或n〕");scanf("%c",&n);getchar();}}while((n=='y'||n=='Y')&&i!=3);}printf(" 数据插入成功!按下任意键返回主菜单...");getch();getchar();}/***********************************输入函数*****************************************/void insert(){FILE *fp;char m,num[30];struct teacher *p1;p1=(struct teacher *)malloc(LEN);if((fp=fopen("save","ab"))==NULL){printf(" 文件不存在!按下任意键返回主菜单...");getch();}else{printf(" 请输入教师信息:\n");do{printf(" ------------------------------\n");printf(" 请输入教工号:");gets(num);p1->num=atoi(num);printf(" 请输入XX:");gets(p1->name);printf(" 请输入性别:");gets(p1->sex);printf(" 请输入单位名称:");gets(p1->workplace);printf(" 请输入家庭住址:");gets(p1->address);printf(" 请输入联系:");gets(num);p1->phone=atoi(num);printf(" 请输入根本工资:");gets(num);p1->de_salary=atof(num);printf(" 请输入津贴:");gets(num);p1->de_jintie=atof(num);printf(" 请输入生活补贴:");gets(num);p1->de_shenghuobutie=atof(num);printf(" 请输入费:");gets(num);p1->cost_phone=atof(num);printf(" 请输入水电费:");gets(num);p1->cost_water_elec=atof(num);printf(" 请输入房租:");gets(num);p1->cost_rent=atof(num);printf(" 请输入个人所得税:");gets(num);p1->cost_tax=atof(num);printf(" 请输入卫生费:");gets(num);p1->cost_weisheng=atof(num);printf(" 请输入公积金:");gets(num);p1->cost_gongjijin=atof(num);p1->yingfa_salary=p1->de_salary+p1->de_jintie+p1->de_shenghuobutie;p1->cost_all=p1->cost_phone+p1->cost_water_elec+p1->cost_rent+p1->cost_tax+p1->cost_weisheng+p1->cost_g ongjijin;p1->shifa_salary=p1->yingfa_salary-p1->cost_all;fwrite(p1,LEN-4,1,fp);printf(" 输入下一个.〔y或n〕");m=getchar();if(m!='y'&&m!='Y'){printf(" 数据保存成功!按下任意键返回主菜单...");getch();}getchar();}while (m=='y'||m=='Y');}fclose(fp);}/***********************************修改函数*****************************************/void modify(){struct teacher *head,*p1,*p2;int i;FILE *fp;char m='n',n='n',num2[30];p1=head=(struct teacher *)malloc(LEN);if((head=load())!=NULL){do{int num=0;char name[20];p1=head;system("cls");printf("\n\n\n >>>>>>>>>>> 修改教师信息<<<<<<<<<<<\n");printf(" *******************************************************\n");printf(" * 1.输入教师号*\n");printf(" * 2.输入XX *\n");printf(" * 3.返回上级菜单*\n");printf(" *******************************************************\n");printf(" 请选择修改式:");scanf("%d",&i);getchar();while (i<1||i>3){printf(" 输入有误!请重新输入:");scanf("%d",&i);getchar();}switch(i){case 1:printf(" 请输入要修改的教师号:");scanf("%d",&num);getchar();while (p1->num!=num){if (p1->next!=NULL)p1=p1->next;else{printf(" 查找不到相关数据!\n");break;}}if (p1->num==num){system("cls");printf("\n\n\n >>>>>欢送使用教师工资管理系统Beta1.2<<<<<\n");printf("----------------------------------原信息如下:---------------------------------\n");printf("教工号XX 性别单位名称家庭住址联系\n");printf(" %-4d %-13s %s %-19s %-19s%-14ld\n",p1->num,p1->name,p1->sex,p1->workplace,p1->address,p1->phone);printf("费水电费房租个人所得税卫生费公积金合计扣款\n");printf(" %-10.1lf %-10.1lf %-10.1lf %-10.1lf %-10.1lf %-10.1lf %-10.1lf\n",p1->cost_phone,p1->cost_water_elec,p1 ->cost_rent,p1->cost_tax,p1->cost_weisheng,p1->cost_gongjijin,p1->cost_all);printf("根本工资津贴生活补贴应发工资实发工资\n");printf(" %-13.1lf %-13.1lf %-13.1lf %-13.1lf %-13.1lf\n",p1->de_salary,p1->de_jintie,p1->de_shenghuobutie,p1->yin gfa_salary,p1->shifa_salary);printf("-------------------------------------------------------------------------------\n");printf(" *******************************************************\n");printf(" * 1.教师号 2.XX *\n");printf(" * 3.性别 4.单位名称*\n");printf(" * 5.家庭住址 6.联系*\n");printf(" * 7.根本工资8.津贴*\n");printf(" * 9.生活补贴10.费*\n");printf(" * 11.水电费12.房租*\n");printf(" * 13.所得税14.卫生费*\n");printf(" * 15.公积金*\n");printf(" *******************************************************\n");do{printf(" 请选择要修改的数据:");scanf("%d",&i);getchar();while (i>15||i<1){printf(" 输入有误!请重新输入:");scanf("%d",&i);getchar();}switch(i){case 1:printf(" 请输入新教师号:");gets(num2);p1->num=atoi(num2);break;case 2:printf(" 请输入新XX:");gets(p1->name);break;case 3:printf(" 请输入新性别:");gets(p1->sex);break;case 4:printf(" 请输入新单位名称:");gets(p1->workplace);break;case 5:printf(" 请输入新家庭住址:");gets(p1->address);break;case 6:printf(" 请输入新联系:");gets(num2);p1->phone=atoi(num2);break;case 7:printf(" 请输入新根本工资:");gets(num2);p1->de_salary=atof(num2);break;case 8:printf(" 请输入新津贴:");gets(num2);p1->de_jintie=atof(num2);break;case 9:printf(" 请输入新生活补贴:");gets(num2);p1->de_shenghuobutie=atof(num2);break;case 10:printf(" 请输入新费:");gets(num2);p1->cost_phone=atof(num2);break;case 11:printf(" 请输入新水电费:");gets(num2);p1->cost_water_elec=atof(num2);break;case 12:printf(" 请输入新房租:");gets(num2);p1->cost_rent=atof(num2);break;case 13:printf(" 请输入新所得税:");gets(num2);p1->cost_tax=atof(num2);break;case 14:printf(" 请输入新卫生费:");gets(num2);p1->cost_weisheng=atof(num2);break;case 15:printf(" 请输入新公积金:");gets(num2);p1->cost_gongjijin=atof(num2);break;default:break;}p1->yingfa_salary=p1->de_salary+p1->de_jintie+p1->de_shenghuobutie;p1->cost_all=p1->cost_phone+p1->cost_water_elec+p1->cost_rent+p1->cost_tax+p1->cost_weisheng+p1->cost_g ongjijin;p1->shifa_salary=p1->yingfa_salary-p1->cost_all;printf(" 继续修改其他数据吗.(y或n):");scanf("%c",&m);getchar();}while (m=='y'||m=='Y');p2=head;if((fp=fopen("save","wb"))==NULL){printf(" 文件不存在!按下任意键返回主菜单...");getch();}else{fwrite(head,LEN-4,1,fp);do{p2=p2->next;fwrite(p2,LEN-4,1,fp);}while(p2->next!=NULL);printf("------------------------------修改后数据如下:---------------------------------\n");printf("教工号XX 性别单位名称家庭住址联系\n");printf(" %-4d %-13s %s %-19s %-19s%-14ld\n",p1->num,p1->name,p1->sex,p1->workplace,p1->address,p1->phone);printf("费水电费房租个人所得税卫生费公积金合计扣款\n");printf(" %-10.1lf %-10.1lf %-10.1lf %-10.1lf %-10.1lf %-10.1lf %-10.1lf \n",p1->cost_phone,p1->cost_water_elec,p1->cost_rent,p1->cost_tax,p1->cost_weisheng,p1->cost_gongjijin,p1->cost_all);printf("根本工资津贴生活补贴应发工资实发工资\n");printf(" %-13.1lf %-13.1lf %-13.1lf %-13.1lf %-13.1lf\n",p1->de_salary,p1->de_jintie,p1->de_shenghuobutie,p1->yin gfa_salary,p1->shifa_salary);printf("-------------------------------------------------------------------------------\n");}fclose(fp);}break;case 2:printf(" 请输入要修改的教师XX:");gets(name);while (strcmp(p1->name,name)!=0){if (p1->next!=NULL)p1=p1->next;else{printf(" 查找不到相关数据!\n");break;}}if (strcmp(p1->name,name)==0){system("cls");printf("\n\n\n >>>>>欢送使用教师工资管理系统Beta1.2<<<<<\n");printf("----------------------------------原信息如下:---------------------------------\n");printf("教工号XX 性别单位名称家庭住址联系\n");printf(" %-4d %-13s %s %-19s %-19s%-14ld\n",p1->num,p1->name,p1->sex,p1->workplace,p1->address,p1->phone);printf("费水电费房租个人所得税卫生费公积金合计扣款\n");printf(" %-10.1lf %-10.1lf %-10.1lf %-10.1lf %-10.1lf %-10.1lf %-10.1lf \n",p1->cost_phone,p1->cost_water_elec,p1->cost_rent,p1->cost_tax,p1->cost_weisheng,p1->cost_gongjijin,p1->cost_all);printf("根本工资津贴生活补贴应发工资实发工资\n");printf(" %-13.1lf %-13.1lf %-13.1lf %-13.1lf %-13.1lf\n",p1->de_salary,p1->de_jintie,p1->de_shenghuobutie,p1->yin gfa_salary,p1->shifa_salary);printf("-------------------------------------------------------------------------------\n");printf(" *******************************************************\n");printf(" * 1.教师号 2.XX *\n");printf(" * 3.性别 4.单位名称*\n");printf(" * 5.家庭住址 6.联系*\n");printf(" * 7.根本工资8.津贴*\n");printf(" * 9.生活补贴10.费*\n");printf(" * 11.水电费12.房租*\n");printf(" * 13.所得税14.卫生费*\n");printf(" * 15.公积金*\n");printf(" *******************************************************\n");do{printf(" 请选择要修改的数据:");scanf("%d",&i);getchar();while (i>15||i<1){printf(" 输入有误!请重新输入:");scanf("%d",&i);getchar();}switch(i){case 1:printf(" 请输入新教师号:");gets(num2);p1->num=atoi(num2);break;case 2:printf(" 请输入新XX:");gets(p1->name);break;case 3:printf(" 请输入新性别:");gets(p1->sex);break;case 4:printf(" 请输入新单位名称:");gets(p1->workplace);break;case 5:printf(" 请输入新家庭住址:");gets(p1->address);break;case 6:printf(" 请输入新联系:");gets(num2);p1->phone=atoi(num2);break;case 7:printf(" 请输入新根本工资:");gets(num2);p1->de_salary=atof(num2);break;case 8:printf(" 请输入新津贴:");gets(num2);p1->de_jintie=atof(num2);break;case 9:printf(" 请输入新生活补贴:");gets(num2);p1->de_shenghuobutie=atof(num2);break;case 10:printf(" 请输入新费:");gets(num2);p1->cost_phone=atof(num2);break;case 11:printf(" 请输入新水电费:");gets(num2);p1->cost_water_elec=atof(num2);break;case 12:printf(" 请输入新房租:");gets(num2);p1->cost_rent=atof(num2);break;case 13:printf(" 请输入新所得税:");gets(num2);p1->cost_tax=atof(num2);break;case 14:printf(" 请输入新卫生费:");gets(num2);p1->cost_weisheng=atof(num2);break;case 15:printf(" 请输入新公积金:");gets(num2);p1->cost_gongjijin=atof(num2);break;default:break;}p1->yingfa_salary=p1->de_salary+p1->de_jintie+p1->de_shenghuobutie;p1->cost_all=p1->cost_phone+p1->cost_water_elec+p1->cost_rent+p1->cost_tax+p1->cost_weisheng+p1->cost_g ongjijin;p1->shifa_salary=p1->yingfa_salary-p1->cost_all;printf(" 继续修改其他数据吗.(y或n):");scanf("%c",&m);getchar();}while (m=='y'||m=='Y');p2=head;if((fp=fopen("save","wb"))==NULL){printf(" 文件不存在!按下任意键返回主菜单...");getch();}else{fwrite(head,LEN-4,1,fp);do{p2=p2->next;fwrite(p2,LEN-4,1,fp);}while(p2->next!=NULL);printf("------------------------------修改后数据如下:---------------------------------\n");printf("教工号XX 性别单位名称家庭住址联系\n");printf(" %-4d %-13s %s %-19s %-19s%-14ld\n",p1->num,p1->name,p1->sex,p1->workplace,p1->address,p1->phone);printf("费水电费房租个人所得税卫生费公积金合计扣款\n");printf(" %-10.1lf %-10.1lf %-10.1lf %-10.1lf %-10.1lf %-10.1lf %-10.1lf \n",p1->cost_phone,p1->cost_water_elec,p1->cost_rent,p1->cost_tax,p1->cost_weisheng,p1->cost_gongjijin,p1->cost_all);printf("根本工资津贴生活补贴应发工资实发工资\n");printf(" %-13.1lf %-13.1lf %-13.1lf %-13.1lf %-13.1lf\n",p1->de_salary,p1->de_jintie,p1->de_shenghuobutie,p1->yin gfa_salary,p1->shifa_salary);printf("-------------------------------------------------------------------------------\n");}fclose(fp);}break;case 3:break;default :break;}if (i!=3){printf("\n 继续修改其他教师的信息吗.〔y或n〕");scanf("%c",&n);}}while((n=='y'||n=='Y')&&i!=3);}}/***********************************删除函数*****************************************/void deletes(){struct teacher *head,*p1,*p2,*p3;int i;char k;FILE *fp;char n='n';p1=p2=p3=(struct teacher *)malloc(LEN);if((head=load())!=NULL){do{int num;char name[20];p1=head;system("cls");printf("\n\n\n >>>>>>>>>>> 删除教师信息<<<<<<<<<<<\n");printf(" *******************************************************\n");printf(" * 1.输入教师号*\n");printf(" * 2.输入XX *\n");printf(" * 3.返回上级菜单*\n");printf(" *******************************************************\n");printf(" 请选择删除式:");scanf("%d",&i);getchar();while (i<1||i>3){printf(" 输入有误!请重新输入:");scanf("%d",&i);getchar();}switch(i){case 1:printf(" 请输入要删除的信息的教师号:");scanf("%d",&num);getchar();while (p1->num!=num){if (p1->next!=NULL)p1=p1->next;else{printf(" 查找不到相关数据!\n");break;}}if (p1->num==num){printf("-----------------------------要删除的信息如下:--------------------------------\n");printf("教工号XX 性别单位名称家庭住址联系\n");printf(" %-4d %-13s %s %-19s %-19s%-14ld\n",p1->num,p1->name,p1->sex,p1->workplace,p1->address,p1->phone);printf("费水电费房租个人所得税卫生费公积金合计扣款\n");printf(" %-10.1lf %-10.1lf %-10.1lf %-10.1lf %-10.1lf %-10.1lf %-10.1lf\n",p1->cost_phone,p1->cost_water_elec,p1 ->cost_rent,p1->cost_tax,p1->cost_weisheng,p1->cost_gongjijin,p1->cost_all);printf("根本工资津贴生活补贴应发工资实发工资\n");printf(" %-13.1lf %-13.1lf %-13.1lf %-13.1lf %-13.1lf\n",p1->de_salary,p1->de_jintie,p1->de_shenghuobutie,p1->yin gfa_salary,p1->shifa_salary);printf("-------------------------------------------------------------------------------\n");printf(" 确定删除吗.〔y或n〕:");scanf("%c",&k);getchar();}if (k=='y'||k=='Y'){if (p1->num==num){if(p1==head){p1=p1->next;p2=p1;}else if(p1->next==NULL){p3=p1;p1=head;p2=head;while(p1->next!=p3){p1=p1->next;}p1->next=NULL;}else{p2=head;p3=p1;p1=head;while(p1->next!=p3){p1=p1->next;}p3=p3->next;p1->next=p3;}if((fp=fopen("save","wb"))==NULL){printf(" 文件不存在!按下任意键返回主菜单...");getch();}else{do{fwrite(p2,LEN-4,1,fp);if(p2->next!=NULL)p2=p2->next;}while(p2->next!=NULL);if(p2!=head)fwrite(p2,LEN-4,1,fp);}fclose(fp);printf(" 删除成功!按下任意键继续...");getch();}}else {printf(" 删除已被取消!按下任意键继续...");getch();}break;case 2:printf(" 请输入要修改的教师XX:");gets(name);while (strcmp((p1->name),name)!=0){if (p1->next!=NULL)p1=p1->next;else{printf(" 查找不到相关数据!\n");break;}}if (strcmp((p1->name),name)==0){printf("-----------------------------要删除的信息如下:--------------------------------\n");printf("教工号XX 性别单位名称家庭住址联系\n");printf(" %-4d %-13s %s %-19s %-19s%-14ld\n",p1->num,p1->name,p1->sex,p1->workplace,p1->address,p1->phone);printf("费水电费房租个人所得税卫生费公积金合计扣款\n");printf(" %-10.1lf %-10.1lf %-10.1lf %-10.1lf %-10.1lf %-10.1lf %-10.1lf \n",p1->cost_phone,p1->cost_water_elec,p1->cost_rent,p1->cost_tax,p1->cost_weisheng,p1->cost_gongjijin,p1->cost_all);printf("根本工资津贴生活补贴应发工资实发工资\n");printf(" %-13.1lf %-13.1lf %-13.1lf %-13.1lf %-13.1lf\n",p1->de_salary,p1->de_jintie,p1->de_shenghuobutie,p1->yin gfa_salary,p1->shifa_salary);printf("-------------------------------------------------------------------------------\n");printf(" 确定删除吗.〔y或n〕:");scanf("%c",&k);getchar();}if (k=='y'||k=='Y'){if (strcmp((p1->name),name)==0){if(p1==head){p1=p1->next;p2=p1;}else if(p1->next==NULL){p3=p1;p1=head;p2=head;while(p1->next!=p3){p1=p1->next;}p1->next=NULL;}else{p2=head;p3=p1;p1=head;while(p1->next!=p3){p1=p1->next;}p3=p3->next;p1->next=p3;}if((fp=fopen("save","wb"))==NULL){printf(" 文件不存在!按下任意键返回主菜单...");getch();}else{do{fwrite(p2,LEN-4,1,fp);if(p2->next!=NULL)p2=p2->next;}while(p2->next!=NULL);if(p2!=head)。
工资管理系统毕业设计附源码工资管理系统是一种用于管理和计算员工工资的软件系统。
它可以帮助企业自动化工资计算、发放和记录,提高工资管理的效率和准确性。
下面是一个简单的工资管理系统的毕业设计附源码的示例。
首先,我们需要设计数据库来存储员工信息和工资数据。
可以使用关系型数据库如MySQL或SQLite。
以下是一个简化的员工表和工资表的设计示例:员工表(employees):employee_id: 员工ID(主键)。
name: 员工姓名。
department: 所属部门。
position: 职位。
工资表(salaries):salary_id: 工资记录ID(主键)。
employee_id: 员工ID(外键)。
salary_date: 工资发放日期。
basic_salary: 基本工资。
bonus: 奖金。
deductions: 扣款。
total_salary: 总工资。
接下来,我们需要开发一个用户界面,让管理员可以输入员工信息和工资数据,并进行工资计算和管理。
可以使用Java编程语言和Swing图形用户界面库来实现。
以下是一个简单的Java代码示例:java.import javax.swing.;import java.awt.;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;public class SalaryManagementSystem extends JFrame {。
// 声明界面组件。
private JTextField idField, nameField, departmentField, positionField;private JTextField dateField, basicSalaryField, bonusField, deductionsField;private JTextArea resultArea;private JButton calculateButton, saveButton;public SalaryManagementSystem() {。
#include〈iostream〉#include<fstream〉#include<iomanip>using namespace std;class person //基类{public:bool mark; //存在标记char name[20];//职工姓名int num; //职工编号double basePay;//基本工资person(bool m,char nm[],int n,double b):mark(m),num(n),basePay(b){strcpy(name,nm);}};class teacher:virtual public person //教师类{public:double classPay;//课时费teacher(bool m,char nm[],int n,double b,double c):person(m,nm,n,b),classPay(c){}void show(){cout〈〈setw(15)<<”职工类型"〈〈setw(10)〈〈"职工编号”〈<setw(10)<〈”职工姓名"〈<setw(10)〈<"基本功资”〈〈setw(10)〈<"课时费"〈〈setw(10)<<”总工资”<<endl;cout〈〈setw(15)〈<”教师"<〈setw(10)〈〈num<〈setw(10)<<name<〈setw(10)〈<basePay〈<setw(10)〈〈classPay<〈setw(10)<<classPay+basePay〈〈endl;}};class lab:virtual public person //实验员类{public:double labPay; //实验室补助lab(bool m,char nm[],int n,double b,double j):person(m,nm,n,b),labPay(j){}void show(){cout<〈setw(15)〈<"职工类型”〈<setw(10)<<"职工编号"<〈setw(10)〈〈"职工姓名”〈〈setw(10)〈<”基本功资”〈<setw(10)〈<”实验补贴”<〈setw(10)〈〈"总工资”〈<endl;cout<〈setw(15)〈〈"实验员”〈〈setw(10)<<num<<setw(10)<<name〈<setw(10)〈<basePay〈<setw(10)<<labPay<〈setw(10)〈〈labPay+basePay〈〈endl;}};class admin:virtual public person //行政人员类{public:double adminPay;//行政补贴admin(bool m,char nm[],int n,double b,double k):person(m,nm,n,b),adminPay(k){}void show(){cout〈<setw(15)<〈"职工类型"<<setw(10)<〈”职工编号"<<setw(10)〈〈"职工姓名”〈〈setw(10)<〈”基本功资"〈<setw(10)〈<"行政补贴"<〈setw(10)〈〈”总工资”〈<endl;cout<<setw(15)<〈"行政人员"<<setw(10)<<num〈<setw(10)<<name〈〈setw(10)<<basePay〈<setw(10)〈〈adminPay<<setw(10)〈<adminPay+basePay〈<endl;}};void add() //添加数据函数{ifstream ifile("E:\\data。
一、课程设计主题介绍本次课程设计的主题为工资管理系统数据库,旨在通过设计一个完善的工资管理系统数据库,实现对公司员工工资信息的管理和查询功能。
工资管理系统是企业日常管理中不可或缺的一部分,良好的工资管理系统能够有效提高企业的管理效率和员工的工作积极性,具有重要的实际意义。
二、系统需求分析1. 用户需求:系统应具有权限管理、员工信息管理、薪资发放管理等功能,不同用户拥有不同的操作权限。
2. 数据需求:系统需要存储员工基本信息、薪资信息、考勤信息等数据。
3. 界面需求:系统应具有友好的操作界面,用户操作简单方便。
4. 安全需求:系统要保证数据的安全性,防止未授权人员获取敏感信息。
三、系统设计思路1. 数据库设计:设计员工表、薪资表、权限表等数据库表结构,确保数据存储的规范性和完整性。
2. 功能设计:设计权限管理模块、员工信息管理模块、薪资发放管理模块等系统功能。
3. 界面设计:设计简洁清晰的操作界面,使用户能够轻松上手。
4. 安全设计:采用加密算法保护用户信息,设置严格的权限控制,防止数据泄露和篡改。
四、系统技术选型本系统选用MySQL数据库存储数据,采用Python语言进行后台逻辑开发,使用Django框架进行Web应用开发,前端界面采用HTML、CSS和JavaScript技术实现。
五、系统功能实现1. 权限管理:管理员用户可以设置不同用户的权限,包括查看员工信息、修改薪资、导出报表等操作。
2. 员工信息管理:实现员工信息的增加、修改、删除、查询等功能,包括基本信息、通联方式、部门信息等。
3. 薪资发放管理:实现对员工薪资的发放、调整、查询等功能,包括工资条生成、导出等。
4. 数据统计报表:系统可以生成各类工资统计报表,包括月度工资报表、年度工资报表等。
六、系统调试和测试在系统开发完成后,对系统进行全面的功能测试和性能测试,确保系统稳定可靠、业务流程正常、响应速度合理等。
七、系统部署和运行系统部署到服务器上,对外提供访问服务,确保系统在日常运行中稳定运行。
#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指向的当前节点占用的内存*/}}。
五、详细设计说明书1.引言 (2)1.1编写目的 (2)1.2项目背景 (2)1.3定义 (3)1.4参考资料 (3)2.总体设计 (4)2.1需求概述 (4)2.2软件结构 (4)3.程序描述 (5)3.1功能 (6)3.2性能......................................................................................................... 错误!未定义书签。
3.3输入项目 (26)3.4输出项目 (26)3.5算法 (26)3.6程序逻辑 (26)3.7接口 (26)3.8存储分配 (26)3.9限制条件 (26)3.10测试要点 (26)1.引言1.1编写目的【阐明编写详细设计说明书的目的,指明读者对象。
】通过《需求规格说明书》、《数据库设计说明书》,在仔细考虑讨论之后,我们对《高校工资管理系统》软件的功能划分、数据结构、软件总体结构的实现有了进一步的想法。
据此,作为详细设计说明书,为进一步设计软件界面、编写代码打下基础。
主要为下面软件具体开发做下规格及统一规定1.2项目背景【应包括项目的来源和主管部门等。
】A.待开发软件系统的名称:《高校工资管理系统》B.随着社会信息量的与日俱增,作为信息存储的主要媒体之一教材,数量、规模比以往任何时候都大的多,老师和学生在选择教材和订购教材时产生了很大的麻烦。
在计算机日益普及的今天,对个人而言若采用一套行之有效的教材订购系统来订购书籍,会方便许多,这也充分应用硬件资源,节省了人力资源。
学校教材订购系统软件是一功能比较完善的数据管理软件,具有数据操作方便高效迅速等优点。
该软件采用功能强大的数据库软件开发工具进行开发,具有很好的可移植性,可在应用范围较广WINDOWS系列等操作系统上使用。
除此以外,可通过访问权限控制以及数据备份功能,确保数据的安全性。
1.3定义【列出文档中所用到的专门术语的定义和缩写词的原文。
面向对象程序设计班级:0703学号:2007115020311姓名:张娣完成时间:二00九年12 月22 日高校工资管理系统一、实验题目要求综合运用封装、继承、多态性、文件流、异常处理来设计和实现简单的信息管理系统二、实验任务设计和实现高校工资管理系统:高校中人员有:行政人员、教师、实验室人员、后勤人员、外聘人员。
通过本系统要求实现以下内容:1)添加职员的基本信息;2)校内人员调离学校删除信息;3)根据工作证号查询校内人员的工资,根据姓名查询外聘人员的工资;4)根据工资计算准则计算总工资;5)分类输出所有人员的信息;6)实现数据保存功能。
三、对象模型四、程序代表性代码#include <iostream.h>#include <string.h>#include <fstream.h>class Person { //人员基类protected:int no;char name[15];double salary;int flag; //标志人员的类型public:Person() {}virtual void setMessage() = 0; //键盘输入数据virtual void setMessage(ifstream& ifs) = 0; //文件输入数据virtual void showMessage() = 0; //输出数据virtual void showMessage(ofstream& ofs) = 0; //输出数据到文件virtual float incoming()=0; //计算收入virtual ~Person() {}virtual char *getName() = 0; // 返回名字virtual int getNo() = 0; //返回证件号码virtual int getFlag() = 0; //返回人员类型};class Teacher:virtual public Person { //教师protected:int workHour;public:Teacher() {flag=1; //标志教师类型salary = 1000; //教师的基本薪水}virtual ~Teacher() {}void setMessage() { //键盘输入教师的基本信息cout<<"工作证号: "; cin>>no;cout<<"姓名: "; cin>>name;cout<<"工作时间: "; cin>>workHour;}void setMessage(ifstream& ifs) { //文件读入教师的基本信息ifs>>flag>>no>>name>>workHour;}void showMessage() { //输出教师的信息cout<<" 工作证号:"<<no<<" 姓名:"<<name<<" 工作时间:"<<workHour<<" 薪水:"<<incoming()<<endl;}void showMessage(ofstream& ofs) {ofs<<flag<<"\t"<<no<<"\t"<<name<<"\t"<<workHour<<"\t"<<endl;}float incoming() { //计算教师的薪水return salary + workHour * 20;}char *getName() {return name;}int getNo() {return no;}int getFlag() {return flag;}};void add(); //增加一位职工void deletePerson(); //按证件号删除一位职工void inserchbyNo(); //根据证件号查询员工工资void inserchbyName(); //根据姓名查询员工工资void save(); //职工信息存盘void load(); //职工信息装入void print(); //分类输出职工信息void clearCollege(); //清除链表};void College::add() {Node *node = new Node; //在头结点head前插入新的结点作为新的头结点Person *person;int flag;cout<<"输入要添加人员的类别"<<endl;cout<<" 1-->普通教师2-->行政人员3-->实验员4-->后勤人员5-->外聘教师"<<endl;cout<<" 选择:";cin >> flag; cout << endl;switch (flag) {case 1:{Teacher *teacher = new Teacher;teacher->setMessage();person = teacher;}break;case 2:{Manager *manager = new Manager;manager->setMessage();person = manager;}break;case 3:{Assistant *assistant = new Assistant;assistant->setMessage();person = assistant;}break;case 4:{Waiter *waiter = new Waiter;waiter->setMessage();person = waiter;}break;case 5:{Employee_Teacher *employee_teacher = new Employee_Teacher;employee_teacher->setMessage();person = employee_teacher;}break;default :break;}node->data = person;if(head==0||head==NULL) {node->next = 0;}else{node->next = head;}head = node;}void College::deletePerson() {int deteleNo;Node *temp1, *temp2;temp1 = head;if(head==0||head->data==NULL) {cout<<"记录中没有员工了!"<<endl;return;}temp2 = head->next;cout <<"请输入职工的编号: ";cin>>deteleNo; cout <<endl;if(head->data->getNo()==deteleNo) {head = head->next;cout<<"删除成功!"<<endl;delete temp1;return;}while(temp2!=NULL) {if(temp2->data->getNo()==deteleNo) {temp1->next = temp2->next;cout<<"删除成功!"<<endl;delete temp2;return;}temp1 =temp2;temp2 = temp2->next;}cout<<"没有此职员!\n"<<endl;}void College::inserchbyNo() {int inserchNo;Node *temp;cout <<"请输入职工的编号: ";cin>>inserchNo; cout <<endl;temp = head;while(temp!=NULL) {if(temp->data->getNo()==inserchNo) {cout<<"职工"<<inserchNo<<"的工资为:"<<temp->data->incoming()<<endl;return;}temp = temp->next;}if(temp==NULL) {cout<<"不存在编号为:"<<inserchNo<<"的职工"<<endl;}}void College::print() {Node *temp;int i;for(i=1; i<=5; i++) { // i由1到5表示5类不同的人员temp = head;switch(i) {case 1:{cout<<"普通教师类信息:"<<endl;while(temp!=NULL) {if(temp->data->getFlag() == 1) {temp->data->showMessage();}temp = temp->next;}}break;case 2:{cout<<"行政人员信息:"<<endl;while(temp!=NULL) {if(temp->data->getFlag() == 2) {temp->data->showMessage();}temp = temp->next;}}break;case 3:{cout<<"实验员信息:"<<endl;while(temp!=NULL) {if(temp->data->getFlag() == 3) {temp->data->showMessage();}temp = temp->next;}}break;case 4:{cout<<"后勤人员信息:"<<endl;while(temp!=NULL) {if(temp->data->getFlag() == 4) {temp->data->showMessage();}temp = temp->next;}}break;case 5:{cout<<"外聘教师信息:"<<endl;while(temp!=NULL) {if(temp->data->getFlag() == 6) {temp->data->showMessage();}temp = temp->next;}}break;}}}void College::clearCollege() {Node *temp;if(head==0||head->data==NULL) {delete head;head = 0;return;}temp = head->next;while(temp!=NULL) {delete head;head = temp;temp = temp->next;}delete head;head = 0;}void College::save() {ofstream f("职工信息.dat",ios::unitbuf); //打开文件//遍历输出至文件Node *temp;temp = head;while(temp!=NULL&&temp!=0) {temp->data->showMessage(f);temp = temp->next;}f.close(); //关闭文件cout<<"职工信息成功保存在‘职工信息.dat’.\n"; }void College::load() {char buf[81]; //临时空间int flag; //人员类型Person *temp; //建立结点指针long t; //读写位置clearCollege(); //清除现有结点(保留头结点)ifstream f("职工信息.dat",ios::in); //打开文件while(true) {t=f.tellg(); //读取人员类型f>>flag;if(f) {switch(flag) {case 1:temp = new Teacher;break;case 2:temp = new Manager;break;case 3:temp = new Assistant;break;case 4:temp = new Waiter;break;case 6:temp = new Employee_Teacher;default :{f.close();cout<<"信息载入成功!"<<endl;return;}}Node *node = new Node;node->data = temp;if(head==NULL||head==0) {node->next = NULL;}else {node->next = head;}head = node;f.seekg(t);temp->setMessage(f);}else{cout<<"数据加载完毕!"<<endl;break;}}}#include <iostream.h>#include <string.h>void main(){char ch;College c; //定义大学对象//显示主菜单,接受选择,并分支调用大学类的相应功能的成员函数do{cout<<"\n**** 高校工资管理系统****\n";cout<<"** 1-增加职工**\n";cout<<"** 2-删除职工**\n";cout<<"** 3-按编号查询职工**\n";cout<<"** 4-按姓名查询职工**\n";cout<<"** 5-分类输出职工信息**\n";cout<<"** 6-数据存盘**\n";cout<<"** 7-数据装入**\n";cout<<"** 0-退出**\n";cout<<"**************************"<<endl;cout<<" 请选择(0-7): ";cin>>ch; cout<<endl;switch(ch){case '1': c.add(); break;case '2': c.deletePerson();break;case '3': c.inserchbyNo();break;case '4': c.inserchbyName();break;case '5': c.print(); break;case '6': c.save(); break;case '7': c.load(); break;default : cout<<"非正常退出!"; return;}}while(ch!='0');}五、运行部分结果六、实验心得本程序成功运用了类、继承、重载、多态以及文件流等面向对象的编程方法,对巩固面向对象编程水平的提高有很大帮助。
#include<iostream>#include<fstream>#include<iomanip>using namespace std;class person //基类{public:bool mark; //存在标记char name[20]; //职工姓名int num; //职工编号double basePay; //基本工资person(bool m,char nm[],int n,double b):mark(m),num(n),basePay(b){strcpy(name,nm);}};class teacher:virtual public person //教师类{public:double classPay; //课时费teacher(bool m,char nm[],int n,double b,double c):person(m,nm,n,b),classPay(c){}void show(){cout<<setw(15)<<"职工类型"<<setw(10)<<"职工编号"<<setw(10)<<"职工姓名"<<setw(10)<<"基本功资"<<setw(10)<<"课时费"<<setw(10)<<"总工资"<<endl;cout<<setw(15)<<"教师"<<setw(10)<<num<<setw(10)<<name<<setw(10)<<basePay<<setw(10)<<classPay<<setw(10)<<classPay+base Pay<<endl;}};class lab:virtual public person //实验员类{public:double labPay; //实验室补助lab(bool m,char nm[],int n,double b,double j):person(m,nm,n,b),labPay(j){}void show(){cout<<setw(15)<<"职工类型"<<setw(10)<<"职工编号"<<setw(10)<<"职工姓名"<<setw(10)<<"基本功资"<<setw(10)<<"实验补贴"<<setw(10)<<"总工资"<<endl;cout<<setw(15)<<"实验员"<<setw(10)<<num<<setw(10)<<name<<setw(10)<<basePay<<setw(10)<<labPay<<setw(10)<<labPay+basePay< <endl;}};class admin:virtual public person //行政人员类{public:double adminPay; //行政补贴admin(bool m,char nm[],int n,double b,double k):person(m,nm,n,b),adminPay(k){}void show(){cout<<setw(15)<<"职工类型"<<setw(10)<<"职工编号"<<setw(10)<<"职工姓名"<<setw(10)<<"基本功资"<<setw(10)<<"行政补贴"<<setw(10)<<"总工资"<<endl;cout<<setw(15)<<"行政人员"<<setw(10)<<num<<setw(10)<<name<<setw(10)<<basePay<<setw(10)<<adminPay<<setw(10)<<adminPay+base Pay<<endl;}};void add() //添加数据函数{ifstream ifile("E:\\data.txt");if(ifile.fail()){ofstream ofile("E:\\data.txt");if(ofile.fail())throw("打开文件失败!");ofile.close();}else ifile.close();fstream file;file.open("E:\\data.txt",ios::in|ios::out|ios::binary);int a,b,c,sign,bh;char xm[20];double jbgz,ksf;cout<<"\t*******************************************************************"<<endl;cout<<"\t* 1.教师 2.实验员 3.行政人员*"<<endl;cout<<"\t*******************************************************************"<<endl;cout<<"\t\t\t请选择添加类型:";cin>>a;switch(a){case 1:{cout<<"\t*******************************************************************"<<endl;cout<<"\t* 1.教授 2.副教授 3.讲师*"<<endl;cout<<"\t*******************************************************************"<<endl;cout<<"\t\t\t请选择添加类型:";cin>>c;switch(c){case 1:{cout<<"\t\t\t输入编号:";cin>>bh;cout<<"\t\t\t输入姓名:";cin>>xm;cout<<"\t\t\t输入基本工资:";cin>>jbgz;cout<<"\t\t\t输入上学期课时工作量:";cin>>b;ksf=b*20;cout<<"\t\t\t课时费:"<<ksf<<endl;cout<<"\t\t\t总工资:"<<ksf+jbgz<<endl;teacher temp(true,xm,bh,jbgz,ksf);sign=1;file.seekg(0,ios::end);file.write((char*)&sign,sizeof(int));file.write((char*)&temp,sizeof(teacher));cout<<"\t\t\t添加成功"<<endl;}break;case 2:{cout<<"\t\t\t输入编号:";cin>>bh;cout<<"\t\t\t输入姓名:";cin>>xm;cout<<"\t\t\t输入基本工资:";cin>>jbgz;cout<<"\t\t\t输入上学期课时工作量:";cin>>b;ksf=b*15;cout<<"\t\t\t课时费:"<<ksf<<endl;cout<<"\t\t\t总工资:"<<ksf+jbgz<<endl;teacher temp(true,xm,bh,jbgz,ksf);sign=2;file.seekg(0,ios::end);file.write((char*)&sign,sizeof(int));file.write((char*)&temp,sizeof(teacher));cout<<"\t\t\t添加成功"<<endl;}break;case 3:{cout<<"\t\t\t输入编号:";cin>>bh;cout<<"\t\t\t输入姓名:";cin>>xm;cout<<"\t\t\t输入基本工资:";cin>>jbgz;cout<<"\t\t\t输入上学期课时工作量:";cin>>b;ksf=b*10;cout<<"\t\t\t课时费:"<<ksf<<endl;cout<<"\t\t\t总工资:"<<ksf+jbgz<<endl;teacher temp(true,xm,bh,jbgz,ksf);sign=3;file.seekg(0,ios::end);file.write((char*)&sign,sizeof(int));file.write((char*)&temp,sizeof(teacher));cout<<"***********************"<<endl;cout<<"\t\t\t添加成功"<<endl;}break;} }break;case 2:{cout<<"\t*******************************************************************"<<endl; cout<<"\t* 1.工程师 2.高级工程师 *"<<endl; cout<<"\t*******************************************************************"<<endl; cout<<"\t\t\t请选择添加类型:";cin>>c;switch(c){case 1:{cout<<"\t\t\t输入编号:";cin>>bh;cout<<"\t\t\t输入姓名:";cin>>xm;cout<<"\t\t\t输入基本工资:";cin>>jbgz;ksf=150;cout<<"\t\t\t实验室补助:"<<ksf<<endl;cout<<"\t\t\t总工资:"<<ksf+jbgz<<endl;lab temp(true,xm,bh,jbgz,ksf);sign=1;file.seekg(0,ios::end);file.write((char*)&sign,sizeof(int));file.write((char*) &temp,sizeof(lab));cout<<"\t\t\t添加成功"<<endl;}break;case 2:{cout<<"\t\t\t输入编号:";cin>>bh;cout<<"\t\t\t输入姓名:";cin>>xm;cout<<"\t\t\t输入基本工资:";cin>>jbgz;ksf=200;cout<<"\t\t\t实验室补助:"<<ksf<<endl;cout<<"\t\t\t总工资:"<<ksf+jbgz<<endl;lab temp(true,xm,bh,jbgz,ksf);sign=2;file.seekg(0,ios::end);file.write((char*) &temp,sizeof(lab));cout<<"\t\t\t添加成功"<<endl;}break;}}break;case 3:{cout<<"\t*******************************************************************"<<endl; cout<<"\t*1.科员 2.科长 3.处长 *"<<endl;cout<<"\t*******************************************************************"<<endl; cout<<"\t\t\t请选择添加类型:";cin>>c;switch(c){case 1:{cout<<"\t\t\t输入编号:";cin>>bh;cout<<"\t\t\t输入姓名:";cin>>xm;cout<<"\t\t\t输入基本工资:";cin>>jbgz;cout<<"\t\t\t输入行政补贴:";cin>>b;cout<<"\t\t\t输入加班费时长:";cin>>ksf;ksf=ksf*20;cout<<"\t\t\t总工资:"<<b+jbgz+ksf<<endl;admin temp(true,xm,bh,jbgz,b);sign=1;file.seekg(0,ios::end);file.write((char*)&sign,sizeof(int));file.write((char*) &temp,sizeof(admin));cout<<"\t\t\t添加成功"<<endl;}break;case 2:{cout<<"\t\t\t输入编号:";cin>>bh;cout<<"\t\t\t输入姓名:";cin>>xm;cout<<"\t\t\t输入基本工资:";cin>>jbgz;cout<<"\t\t\t输入行政补贴:";cin>>b;cout<<"\t\t\t输入加班费时长:";cin>>ksf;ksf=ksf*25;cout<<"\t\t\t总工资:"<<b+jbgz+ksf<<endl;admin temp(true,xm,bh,jbgz,b);sign=2;file.seekg(0,ios::end);file.write((char*)&sign,sizeof(int));file.write((char*) &temp,sizeof(admin));cout<<"\t\t\t添加成功"<<endl;}break;case 3:{cout<<"\t\t\t输入编号:";cin>>bh;cout<<"\t\t\t输入姓名:";cin>>xm;cout<<"\t\t\t输入基本工资:";cin>>jbgz;cout<<"\t\t\t输入行政补贴:";cin>>b;cout<<"\t\t\t输入加班费时长:";cin>>ksf;ksf=ksf*30;cout<<"\t\t\t总工资:"<<b+jbgz+ksf<<endl;admin temp(true,xm,bh,jbgz,b);sign=3;file.seekg(0,ios::end);file.write((char*)&sign,sizeof(int));cout<<"\t\t\t添加成功"<<endl;}break;}}break;file.close();}}void search() //查询修改函数{ifstream ifile("E:\\data.txt");if(ifile.fail()){ofstream ofile("E:\\data.txt");if(ofile.fail())throw("打开失败");ofile.close();}else ifile.close();fstream file;file.open("E:\\data.txt",ios::in|ios::out|ios::binary);int a,b,sign,g=0;char tag,y[20];cout<<"\t*******************************************************************"<<endl;cout<<"\t* 1.职工编号查询 2.职工姓名查询 3.显示所有数据*"<<endl;cout<<"\t*******************************************************************"<<endl;cout<<"\t\t\t请选择:";cin>>b;while(b!=1 && b!=2 && b!=3 && b!=4 && b!=5){cout<<"\t\t\t输入不符,重新输入:";cin>>b;}if(b==1){cout<<"\t\t\t输入要查询的职工编号:";cin>>a;file.seekg(0);file.read((char*)&sign,sizeof(int));while(!file.eof()){if(sign==1){teacher temp(true,"s",0,0,0);file.read((char*)&temp,sizeof(teacher));if(temp.num==a && temp.mark){temp.show();cout<<"\t\t\t是否要修改数据?(Y/N):";cin>>tag;tag=tolower(tag);while(tag!='y' && tag!='n'){cout<<"\t\t\t输入不符,重新输入(Y/N):";cin>>tag;tag=tolower(tag);}if(tag=='y'){temp.mark=false;file.seekg(sizeof(teacher),ios::cur);file.write((char*)&temp,sizeof(teacher));cout<<"\t*******************************************************************\n\t\t\t\t请输入修改后的数据:\n\t*******************************************************************"<<endl; add();}else{cout<<"**********"<<endl;cout<<"\t\t\t修改已取消"<<endl;}g=1;break;}}if(sign==2){lab temp(true,"s",0,0,0);file.read((char*)&temp,sizeof(lab));if(temp.num==a && temp.mark){temp.show();cout<<"\t\t\t是否要修改数据?(Y/N):";cin>>tag;tag=tolower(tag);while(tag!='y' && tag!='n'){cout<<"\t\t\t输入不符,重新输入(Y/N):";cin>>tag;tag=tolower(tag);}if(tag=='y'){temp.mark=false;file.seekg(sizeof(lab),ios::cur);file.write((char*)&temp,sizeof(lab));cout<<"\t*******************************************************************\n\t\t\t\t请输入修改后的数据:\n\t*******************************************************************"<<endl; add();}else{cout<<"———————"<<endl;cout<<"\t\t\t修改已取消"<<endl;}g=1;break;}}if(sign==3){admin temp(true,"s",0,0,0);file.read((char*)&temp,sizeof(admin));if(temp.num==a && temp.mark){temp.show();cout<<"\t\t\t是否要修改数据?(Y/N):";cin>>tag;tag=tolower(tag);while(tag!='y' && tag!='n'){cout<<"\t\t\t输入不符,重新输入(Y/N):";cin>>tag;tag=tolower(tag);}if(tag=='y'){temp.mark=false;file.seekg(sizeof(admin),ios::cur);file.write((char*)&temp,sizeof(admin));cout<<"\t*******************************************************************\n\t\t\t\t请输入修改后的数据:\n\t*******************************************************************"<<endl; add();}else{cout<<"************"<<endl;cout<<"\t\t\t修改已取消"<<endl;}g=1;break;}}file.read((char*)&sign,sizeof(int));}if(g==0){cout<<"*********"<<endl;cout<<"\t\t\t没有记录!"<<endl;}}if(b==2){cout<<"\t\t\t输入要查询的职工姓名:";cin>>y;file.seekg(0);file.read((char*)&sign,sizeof(int));while(!file.eof()){if(sign==1){teacher temp(true,"s",0,0,0);file.read((char*)&temp,sizeof(teacher));if(strcmp(,y)==0 && temp.mark){temp.show();cout<<"\t\t\t是否要修改数据?(Y/N):";cin>>tag;tag=tolower(tag);while(tag!='y' && tag!='n'){cout<<"\t\t\t输入不符,重新输入(Y/N):";cin>>tag;tag=tolower(tag);}if(tag=='y'){temp.mark=false;file.seekg(sizeof(teacher),ios::cur);file.write((char*)&temp,sizeof(teacher));cout<<"\t*******************************************************************\n\t\t\t\t请输入修改后的数据:\n\t*******************************************************************"<<endl; add();}else{cout<<"***********"<<endl;cout<<"\t\t\t修改已取消"<<endl;}g=1;break;}}if(sign==2){lab temp(true,"s",0,0,0);file.read((char*)&temp,sizeof(lab));if(strcmp(,y)==0 && temp.mark){temp.show();cout<<"\t\t\t是否要修改数据?(Y/N):";cin>>tag;tag=tolower(tag);while(tag!='y' && tag!='n'){cout<<"\t\t\t输入不符,重新输入(Y/N):";cin>>tag;tag=tolower(tag);}if(tag=='y'){temp.mark=false;file.seekg(sizeof(lab),ios::cur);file.write((char*)&temp,sizeof(lab));cout<<"\t*******************************************************************\n\t\t\t\t请输入修改后的数据:\n\t*******************************************************************"<<endl; add();}else{cout<<"***********"<<endl;cout<<"\t\t\t修改已取消"<<endl;}g=1;break;}}if(sign==3){admin temp(true,"s",0,0,0);file.read((char*)&temp,sizeof(admin));if(strcmp(,y)==0 && temp.mark){temp.show();cout<<"\t\t\t是否要修改数据?(Y/N):";cin>>tag;tag=tolower(tag);while(tag!='y' && tag!='n'){cout<<"\t\t\t输入不符,重新输入(Y/N):";cin>>tag;tag=tolower(tag);}if(tag=='y'){temp.mark=false;file.seekg(sizeof(admin),ios::cur);file.write((char*)&temp,sizeof(admin));cout<<"\t*******************************************************************\n\t\t\t\t请输入修改后的数据:\n\t*******************************************************************"<<endl; add();}else{cout<<"*************"<<endl;cout<<"\t\t\t修改已经取消"<<endl;}g=1;break;}}file.read((char*)&sign,sizeof(int));}if(g==0){cout<<"**********"<<endl;cout<<"\t\t\t没有记录"<<endl;}}if(b==3){file.seekg(0);file.read((char*)&sign,sizeof(int));while(!file.eof()){if(sign==1){teacher temp(true,"s",0,0,0);file.read((char*)&temp,sizeof(teacher));if(temp.mark){temp.show();g=1;}}if(sign==2){lab temp(true,"s",0,0,0);file.read((char*)&temp,sizeof(lab));if(temp.mark){temp.show();g=1;}}if(sign==3){admin temp(true,"s",0,0,0);file.read((char*)&temp,sizeof(admin));if(temp.mark){temp.show();g=1;}}file.read((char*)&sign,sizeof(int));}if(g==0){cout<<"**********"<<endl;cout<<"\t\t\t没有记录"<<endl;}}file.close();}void del() //删除数据函数{ifstream ifile("E:\\data.txt");if(ifile.fail()){ofstream ofile("E:\\data.txt");if(ofile.fail())throw("打开文件失败!");ofile.close();}else ifile.close();fstream file;file.open("E:\\data.txt",ios::in|ios::out|ios::binary);int a,sign,g=0;char tag;cout<<"\t*******************************************************************\n\t\t\t\t输入要删除的职工编号:\n\t*******************************************************************";cin>>a; file.seekg(0);file.read((char*)&sign,sizeof(int));while(!file.eof()){if(sign==1){teacher temp(true,"s",0,0,0);file.read((char*)&temp,sizeof(teacher));if(temp.num==a && temp.mark){temp.show();cout<<"\t\t\t是否要删除?(Y/N):";cin>>tag;tag=tolower(tag);while(tag!='y' && tag!='n'){cout<<"\t\t\t输入不符,重新输入(Y/N):";cin>>tag;tag=tolower(tag);}if(tag=='y'){temp.mark=false;file.seekg(sizeof(teacher),ios::cur);file.write((char*)&temp,sizeof(teacher));cout<<"**********"<<endl;cout<<"\t\t\t删除成功!"<<endl;}else{cout<<"**********"<<endl;cout<<"\t\t\t删除已取消!"<<endl;}g=1;break;}}if(sign==2){lab temp(true,"s",0,0,0);file.read((char*)&temp,sizeof(lab));if(temp.num==a && temp.mark){temp.show();cout<<"\t\t\t是否要删除?(Y/N):";cin>>tag;tag=tolower(tag);while(tag!='y' && tag!='n'){cout<<"\t\t\t输入不符,重新输入(Y/N):";cin>>tag;tag=tolower(tag);}if(tag=='y'){temp.mark=false;file.seekg(sizeof(lab),ios::cur);file.write((char*)&temp,sizeof(lab));cout<<"**********"<<endl;cout<<"\t\t\t删除成功"<<endl;}else{cout<<"**********"<<endl;cout<<"\t\t\t删除取消"<<endl;}g=1;break;}}if(sign==3){admin temp(true,"s",0,0,0);file.read((char*)&temp,sizeof(admin));if(temp.num==a && temp.mark){temp.show();cout<<"*******************************************************************\n\t\t\t\t是否要删除?(Y/N):\n*******************************************************************";cin>>tag;tag=tolower(tag) ;while(tag!='y' && tag!='n'){cout<<"\t\t\t输入不符,重新输入(Y/N):";cin>>tag;tag=tolower(tag);}if(tag=='y'){temp.mark=false;file.seekg(sizeof(admin),ios::cur);file.write((char*)&temp,sizeof(admin));cout<<"**********"<<endl;cout<<"\t\t\t删除成功"<<endl;}else{cout<<"**********"<<endl;cout<<"\t\t\t删除成功"<<endl;}g=1;break;}}file.read((char*)&sign,sizeof(int));}if(g==0)cout<<"\t\t\t无记录!"<<endl;file.close();}void end() //重组退出函数{ifstream ifile("E:\\data.txt");if(ifile.fail()){ofstream ofile("E:\\data.txt");if(ofile.fail())throw("打开失败");ofile.close();}else ifile.close();fstream file;file.open("E:\\data.txt",ios::in|ios::out|ios::binary);ofstream outfile("E:\\tem.txt",ios::out|ios::binary);int sign;file.seekg(0);file.read((char*)&sign,sizeof(int));while(!file.eof()){if(sign==1){teacher temp(true,"s",0,0,0);file.read((char*)&temp,sizeof(teacher));if(temp.mark==true){outfile.write((char*)&sign,sizeof(int));outfile.write((char*)&temp,sizeof(teacher));}}if(sign==2){lab temp(true,"s",0,0,0);file.read((char*)&temp,sizeof(lab));if(temp.mark==true){outfile.write((char*)&sign,sizeof(int));outfile.write((char*)&temp,sizeof(lab));}}if(sign==3){admin temp(true,"s",0,0,0);file.read((char*)&temp,sizeof(admin));if(temp.mark==true){outfile.write((char*)&sign,sizeof(int));outfile.write((char*)&temp,sizeof(admin));}}file.read((char*)&sign,sizeof(int));}file.close();outfile.close();remove("E:\\data.txt");rename("E:\\tem.txt","E:\\data.txt");}void main(){int a;do{cout<<"\n\t*******************************************************************\n"; cout<<"\n\t * 高校工资管理系统 * \n"; cout<<"\n\t*******************************************************************\n"; cout<<"\n\t\t\t\t1.数据输入"<<endl;cout<<"\n\t\t\t\t2.数据查询与修改"<<endl;cout<<"\n\t\t\t\t3.删除相关数据"<<endl;cout<<"\n\t\t\t\t4.退出本程序"<<endl;cout<<"\n\t\t\t请输入序号实现相应功能:";cin>>a;switch(a){case 1:add();break;case 2:search();break;case 3:del();break;case 4:end();break;}}while(a!=4);}。