教师工资管理系统C实现

合集下载

C-教师工资管理系统(分析-代码)-PPT课件

C-教师工资管理系统(分析-代码)-PPT课件

void Output(ofstream& ofs) { ofs<<No<<" "<<Name<<" "<<Duty<<" "<<Hours<<endl; }
double Incoming() { return Salary+(Hours-120)*20; } };
class Assistant:virtual public Person //实验员 { protected: int Allowance; int Hours;
<<CppFriend>>
Person
#No: int #Name: char #Duty: char #Salary: double #next: Person
<<create>>-Person() <<destroy>>-Person()
+Input(): void +Input(ifs: ifstream): void +Output(): void +Output(ofs: ofstream): void +Incoming(): double
Assistant
#Allowance: int #Hours: int
<<create>>-Assistant() +Input(): void +Input(ifs: ifstream): void +Output(): void +Output(ofs: ofstream): void +Incoming(): double

C语言 课程设计 教师工资管理系统(职工工资管理系统)

C语言 课程设计 教师工资管理系统(职工工资管理系统)

课程设计教师工资管理系统运行平台: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 welcome(){printf("\n\n\n >>>>>欢迎使用教师工资管理系统Beta1.2<<<<<\n");printf(" *******************************************************\n");printf(" * C语言课程设计教师工资管理系统*\n");printf(" * 班级:电气信息类1001班学号:0909100119 *\n");printf(" * 姓名:弓箭*\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(" 请输入姓名:");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_go ngjijin;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.输入姓名*\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("教工号姓名性别单位名称家庭住址联系电话\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_ele c,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->yingfa_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(" 请输入要插入的教师姓名:");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("教工号姓名性别单位名称家庭住址联系电话\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_al l);printf("基本工资津贴生活补贴应发工资实发工资\n");printf(" %-13.1lf %-13.1lf %-13.1lf %-13.1lf %-13.1lf\n",p1->de_salary,p1->de_jintie,p1->de_shenghuobutie,p1->yingfa_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(" 请输入姓名:");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_go ngjijin;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.输入姓名*\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("教工号姓名性别单位名称家庭住址联系电话\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_ele c,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->yingfa_salary,p1->shifa_salary);printf("-------------------------------------------------------------------------------\n");printf(" *******************************************************\n");printf(" * 1.教师号 2.姓名*\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(" 请输入新姓名:");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_go ngjijin;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();}elsefwrite(head,LEN-4,1,fp);do{p2=p2->next;fwrite(p2,LEN-4,1,fp);}while(p2->next!=NULL);printf("------------------------------修改后数据如下:---------------------------------\n");printf("教工号姓名性别单位名称家庭住址联系电话\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_al l);printf("基本工资津贴生活补贴应发工资实发工资\n");printf(" %-13.1lf %-13.1lf %-13.1lf %-13.1lf %-13.1lf\n",p1->de_salary,p1->de_jintie,p1->de_shenghuobutie,p1->yingfa_salary,p1->shifa_salary);printf("-------------------------------------------------------------------------------\n");}fclose(fp);}break;case 2:printf(" 请输入要修改的教师姓名:");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("教工号姓名性别单位名称家庭住址联系电话\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_al l);printf("基本工资津贴生活补贴应发工资实发工资\n");printf(" %-13.1lf %-13.1lf %-13.1lf %-13.1lf %-13.1lf\n",p1->de_salary,p1->de_jintie,p1->de_shenghuobutie,p1->yingfa_salary,p1->shifa_salary);printf("-------------------------------------------------------------------------------\n");printf(" *******************************************************\n");printf(" * 1.教师号 2.姓名*\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(" 请输入新姓名:");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_go ngjijin;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("教工号姓名性别单位名称家庭住址联系电话\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_al l);printf("基本工资津贴生活补贴应发工资实发工资\n");printf(" %-13.1lf %-13.1lf %-13.1lf %-13.1lf %-13.1lf\n",p1->de_salary,p1->de_jintie,p1->de_shenghuobutie,p1->yingfa_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.输入姓名*\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("教工号姓名性别单位名称家庭住址联系电话\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_ele c,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->yingfa_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(" 请输入要修改的教师姓名:");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("教工号姓名性别单位名称家庭住址联系电话\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_al l);printf("基本工资津贴生活补贴应发工资实发工资\n");printf(" %-13.1lf %-13.1lf %-13.1lf %-13.1lf %-13.1lf\n",p1->de_salary,p1->de_jintie,p1->de_shenghuobutie,p1->yingfa_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)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);}}while((n=='y'||n=='Y')&&i!=3);}。

C语言 教师工资管理系统设计

C语言    教师工资管理系统设计

《程序设计基础》课程设计报告教师工资管理系统设计目录问题概述------------------------------------------------ 1 系统目标------------------------------------------------ 1 设计的过程及步骤---------------------------------------- 2 函数设计------------------------------------------------ 3 系统实现------------------------------------------------ 7 总结--------------------------------------------------- 17 参考文献----------------------------------------------- 18一.问题概述随着时代的进步,人们越来越认识到教育的重要性,科教兴国是十分可行的政策,而教师则是教育事业最重要的一环,他们的付出是我们国家富强的根本保证。

现阶段,各学校的教师数量越来越多,工资、工作安排等方面管理起来就越来越麻烦,这十分不利于教育事业的大步前进,设计出一款用于教师工资管理的程序很有必要,通过系统的C语言学习,我们已经能够通过自己编写程序实现这一目的,进行教师信息的录入,管理,查询等方面的操作,进而推动教育事业的进步。

二.系统目标2.1 (对系统技术的目标)根据所学的程序设计基础原理与程序设计的知识,能够针对一个小型的程序设计基础管理系统,进行系统的需求分析,系统设计,程序设计基础设计,编码,测试等,完成题目要求的功能,从而达到掌握开发一个小型系统程序设计的目的。

2.2 (对系统技术的要求)1. 教师信息及教师工资信息的录入功能(录入数据以文件形式存储)2.教师工资查询功能(至少提供两种及两种以上查询方法)(1)按教师编号进行查询(2)按所在部门进行查询……注:查询结果用链表的形式保存并输出3.教师工资的统计功能4.教师工资的修改功能(如晋升职称后)三、设计的过程及步骤1.需求分析(描述系统需求,既详细分析系统需求和功能)根据题目要求,应当把教师信息用结构体形式输入,再定义一个全局变量和文件指针进行整个程序的运行,然后把教师信息送到文件中,所以应该提供一个结构体和文件的输入输出等操作;在程序中需实现教师信息录入,查询,删除和修改等功能的操作,所以需要建立相应的模块来实现;另外还需提供键盘式选择菜单实现功能,在运行时达到所要目的。

工资管理系统课程设计c语言

工资管理系统课程设计c语言

工资管理系统课程设计c语言一、课程目标知识目标:1. 学生能够理解工资管理系统的基本功能需求,掌握C语言实现工资管理系统所需的基本语法和结构;2. 学生能够运用结构体、数组、文件操作等C语言知识模块,实现工资管理系统中数据的存储、查询、修改和删除等功能;3. 学生了解并掌握C语言中的模块化编程思想,将工资管理系统划分为独立的功能模块,提高代码的可读性和可维护性。

技能目标:1. 学生能够运用所学知识,独立完成一个简单的工资管理系统的设计、编码和调试;2. 学生掌握利用C语言进行系统分析、设计和实现的基本方法,具备基本的编程实践能力;3. 学生能够运用调试工具和技巧,对程序进行调试和优化,提高程序运行的稳定性和效率。

情感态度价值观目标:1. 学生通过本课程的学习,培养对编程的兴趣,提高问题解决能力和创新意识;2. 学生在团队协作中,学会沟通、分享和合作,培养良好的团队精神和职业素养;3. 学生认识到编程在工资管理系统等实际应用中的重要性,激发其学习热情,培养积极的学习态度。

课程性质:本课程为高年级C语言程序设计课程的实践环节,旨在让学生通过实际项目的开发,巩固所学知识,提高编程能力。

学生特点:学生已经具备一定的C语言基础,了解基本语法和编程技巧,但实际项目经验不足。

教学要求:结合学生特点,课程设计应注重实践性、实用性和综合性,引导学生运用所学知识解决实际问题,提高编程实践能力。

在教学过程中,关注学生的个体差异,提供适当的指导和帮助,确保学生能够达到预定的学习目标。

通过课程目标的分解,为后续教学设计和评估提供明确的方向。

二、教学内容1. 工资管理系统需求分析:介绍工资管理系统的基本功能,如员工信息管理、工资计算、数据存储与查询等。

教材章节:《C语言程序设计》第十章——文件。

2. C语言基础知识回顾:回顾结构体、数组、指针等基本概念及其在工资管理系统中的应用。

教材章节:《C语言程序设计》第三章——结构体与联合;《C语言程序设计》第四章——数组与字符串;《C语言程序设计》第五章——指针。

教师工资管理系统c语言课设报告

教师工资管理系统c语言课设报告

教师工资管理系统c语言课设报告1. 项目背景教师工资管理系统是一种为学校或教育机构管理教师工资的软件系统。

在传统的工资管理方式中,人工计算和记录容易出错,效率低下。

而使用教师工资管理系统,可以提高工资管理的准确性和效率,节省人力成本。

2. 项目目标本项目旨在设计和实现一个简单的教师工资管理系统,具备以下功能:1. 教师信息的录入、修改和删除;2. 工资计算和生成工资单;3. 工资查询和统计。

3. 项目设计3.1 数据结构设计根据教师工资管理系统的需求,在设计数据结构时需要考虑以下几个要素:1. 教师信息:包括教师工号、姓名、性别、职称、基本工资等。

2. 工资单:包括工资单号、发放时间、应发金额、实发金额等。

根据需求,可以设计以下数据结构:ctypedef struct {int teacherId; 教师工号char name[20]; 姓名char gender[5]; 性别char title[20]; 职称float basicSalary; 基本工资} Teacher;typedef struct {int salaryId; 工资单号char distributeTime[20]; 发放时间float shouldPay; 应发金额float actualPay; 实发金额} Salary;3.2 模块划分根据项目目标,可以将教师工资管理系统划分为以下几个模块:1. 教师信息管理模块:实现教师信息的录入、修改和删除功能。

2. 工资管理模块:实现工资计算、生成工资单、工资查询和统计功能。

3. 界面模块:实现系统的交互界面,使用户能够方便地操作系统。

4. 项目实现4.1 教师信息管理模块教师信息管理模块主要包括教师信息的录入、修改和删除功能。

可以使用文件操作来实现数据的存储和读取。

4.2 工资管理模块工资管理模块主要包括工资计算、生成工资单、工资查询和统计功能。

4.2.1 工资计算工资计算是根据教师的基本工资和绩效考核来计算教师的应发金额。

教师工资管理系统C实现

教师工资管理系统C实现
exit(0);
}
//添加记录
void tea_new()
{
printf("请输入教师号:");
scanf("%d",&tea[num].number);
printf("请输入教师姓名:");
scanf("%s",tea[num].name);
printf("请输入教师基本工资:");
scanf("%f",&tea[num].salary);
参数 无
返回值 整个信息
工作方式 调用 number
5)原型void search_name;
功能 查找信息 按姓名查找
参数 无
返回值 整个信息
工作方式 调用char name
6)原型void delete_id
功能 删除数据 按编号删除
参数 无
返回值 无
工作方式 调用id
7)原型void change_id;
A、教师信息处理
(1)输入教师信息
(2)插入(修改)教师信息:
(3)删除教师信息:
(4)浏览教师信息:
提示:具体功能及操作参考题1。
B、教师数据处理:
(1)按教师号录入教师基本工资、津贴、生活补贴、电话费、水电费、房租、所得税、卫生费、公积金等基本数据。
(2) 教师实发工资、应发工资、合计扣款计算。
教师工资管理系统
一.选题背景
二.需求分析
1.选题要求:
教师工资管理系统
每个教师的信息为:教师号、姓名、性别、单位名称、家庭住址、联系电话、基本工资、津贴、生活补贴、应发工资、电话费、水电费、房租、所得税、卫生费、公积金、合计扣款、实发工资。注:应发工资=基本工资+津贴+生活补贴;合计扣款=电话费+水电费+房租+所得税+卫生费+公积金;实发工资=应发工资-合计扣款。

C课程设计《工资管理系统》

C课程设计《工资管理系统》

C 课程设计《工资管理系统》一、教学目标本课程的目标是让学生掌握工资管理系统的开发和应用。

通过本课程的学习,学生将能够理解工资管理系统的原理,熟悉工资管理系统的开发流程,掌握工资管理系统的操作方法,并能够运用工资管理系统解决实际问题。

具体来说,知识目标包括掌握工资管理系统的概念、特点和应用领域;技能目标包括能够使用工资管理系统进行工资计算、工资条发放和管理;情感态度价值观目标包括培养学生对工资管理系统的兴趣,提高学生对信息化管理的重要性的认识。

二、教学内容本课程的教学内容主要包括工资管理系统的原理、开发流程和操作方法。

首先,将介绍工资管理系统的概念、特点和应用领域,使学生了解工资管理系统的基本情况。

然后,将讲解工资管理系统的开发流程,包括需求分析、系统设计、编码实现和测试等步骤,使学生掌握工资管理系统的开发方法。

接下来,将介绍工资管理系统的操作方法,包括工资计算、工资条发放和管理等功能,使学生能够熟练使用工资管理系统。

三、教学方法为了实现教学目标,将采用多种教学方法,包括讲授法、讨论法、案例分析法和实验法等。

首先,通过讲授法向学生传授工资管理系统的相关知识,使学生掌握基本概念和原理。

然后,通过讨论法引导学生进行思考和讨论,提高学生对工资管理系统的理解和应用能力。

接着,通过案例分析法让学生分析实际案例,培养学生解决实际问题的能力。

最后,通过实验法让学生动手实践,熟练掌握工资管理系统的操作方法。

四、教学资源为了支持教学内容和教学方法的实施,将选择和准备适当的教学资源。

教材方面,将选用权威、实用的工资管理系统教材,为学生提供系统的理论知识。

参考书方面,将推荐一些与工资管理系统相关的书籍,供学生深入学习和参考。

多媒体资料方面,将制作课件、演示文稿等,以图文并茂的形式展示工资管理系统的原理和操作方法。

实验设备方面,将准备计算机、投影仪等设备,为学生提供良好的学习环境和实践条件。

五、教学评估本课程的评估方式将包括平时表现、作业和考试等。

工资管理系统课程设计C语言

工资管理系统课程设计C语言

工资管理系统 课程设计 C语言一、课程目标知识目标:1. 理解工资管理系统的基本概念和功能需求;2. 掌握C语言中的基本数据类型、运算符、控制结构等编程知识点;3. 学会使用C语言设计并实现一个简单的工资管理系统。

技能目标:1. 能够运用C语言编写出结构清晰、逻辑合理的程序代码;2. 能够运用数组、结构体等数据结构存储和管理工资数据;3. 能够运用文件操作实现工资数据的持久化存储。

情感态度价值观目标:1. 培养学生解决问题的能力和团队协作精神,激发学生对编程的兴趣;2. 增强学生对信息技术的认识,使其意识到信息技术在现实生活中的应用价值;3. 培养学生严谨、认真的学习态度,提高学生的编程素养。

课程性质:本课程为C语言编程实践课,旨在让学生通过动手实践,掌握C语言编程的基本技能,并能够运用所学知识解决实际问题。

学生特点:学生为高年级学生,已具备一定的C语言基础,有较强的逻辑思维能力,但对实际应用场景的编程经验不足。

教学要求:结合学生特点,注重实践操作,引导学生从实际问题出发,逐步培养编程思维,提高编程能力。

课程目标分解为具体学习成果,便于教学设计和评估。

二、教学内容1. 工资管理系统概述- 系统需求分析- 功能模块划分2. C语言基础知识回顾- 数据类型- 运算符与表达式- 控制结构(顺序、分支、循环)3. 数据结构设计- 数组- 结构体4. 函数与模块化编程- 函数定义与调用- 模块化设计5. 文件操作- 文件打开与关闭- 文件读写操作6. 工资管理系统功能实现- 员工信息管理- 工资计算- 工资查询- 数据存储与读取7. 测试与调试- 功能测试- 性能测试- 代码调试教学内容安排与进度:第1周:工资管理系统概述及需求分析第2周:C语言基础知识回顾第3周:数据结构设计第4周:函数与模块化编程第5周:文件操作第6周:工资管理系统功能实现(1)第7周:工资管理系统功能实现(2)第8周:测试与调试教材章节及内容:《C语言程序设计》第3章:数据类型、运算符与表达式第4章:控制结构第6章:函数与模块化编程第7章:数组和字符串第8章:结构体与共同体第9章:文件操作教学内容紧密结合课程目标,注重科学性和系统性,通过以上教学内容,使学生能够掌握C语言编程的核心知识,并能够将其应用于工资管理系统的设计与实现。

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

教师工资管理系统一.选题背景二.需求分析一、设计选题与目标1.选题要求:教师工资管理系统每个教师的信息为:教师号、姓名、性别、单位名称、家庭住址、联系电话、基本工资、津贴、生活补贴、应发工资、电话费、水电费、房租、所得税、卫生费、公积金、合计扣款、实发工资。

注:应发工资=基本工资+津贴+生活补贴;合计扣款=电话费+水电费+房租+所得税+卫生费+公积金;实发工资=应发工资-合计扣款。

A、教师信息处理(1)输入教师信息(2) 插入(修改)教师信息:(3) 删除教师信息:(4) 浏览教师信息:提示:具体功能及操作参考题1。

B、教师数据处理:(1) 按教师号录入教师基本工资、津贴、生活补贴、电话费、水电费、房租、所得税、卫生费、公积金等基本数据。

(2) 教师实发工资、应发工资、合计扣款计算。

提示:计算规则如题目。

(3) 教师数据管理提示:输入教师号,读出并显示该教师信息,输入新数据,将改后信息写入文件(4) 教师数据查询:提示:输入教师号或其他信息,即读出所有数据信息,并显示出来。

(5) 教师综合信息输出提示:输出教师信息到屏幕。

2.目标教师数据处理:(1) 按教师号录入教师基本工资、津贴、生活补贴、电话费、水电费、房租、所得税、卫生费、公积金等基本数据。

(2) 教师实发工资、应发工资、合计扣款计算。

计算规则如题目。

(3) 教师数据管理输入教师号,读出并显示该教师信息,输入新数据,将改后信息写入文件(4) 教师数据查询:输入教师号或其他信息,即读出所有数据信息,并显示出来。

(5) 教师综合信息输出输出教师信息到屏幕三.总体设计利用六个模块分别实现教师信息的输入,修改,删除,查询,保存以及信息文件的读入功能。

并使用不同的函数实现不同的功能。

使用链表存储及处理数据。

程序流程图如下:四.详细设计1.功能模块共分为六个模块:(1)输入教师信息模块在主菜单中运用结构体teacher,输入教师信息,首先建立链表,将用户信息储存到链表中,输入完成后提示用户是否继续输入,如果用户输入“Y”,则再次调用,实现继续输入教师信息的操作。

如果用户输入”NO“,则返回主菜单界面。

(2)修改教师信息模块在主函数中调用void change_id(),修改记录操作需要对数组中目标元素的数据域中的值进行操作。

首先请用户输入要修改的教师编号,然后若找到该记录就提示用户输入各个信息。

(3)删除教师信息模块在主函数中调用void delete_id(),以删除教师信息,首先按学号查询教师信息,如果没有找到教师信息,给出提示。

如果找到教师信息,将教师信息显示出来,提示用户删除。

(4)查询教师信息查询分三种,调用void show_all()显示所有教师信息;调用void search_id()按编号查询教师信息;调用void search_name()按姓名查询教师信息。

(5)读入教师信息文件模块调用void readfromfile()函数从文件导入教师信息(6)保存并退出模块调用void writetofile()写入文件。

2.函数的设计与调用(1)主函数的设计编写主函数的主要任务就是确定调用函数以及控制屏幕显示。

(2)其他函数1)原型void show_all;功能展出所有录入文件参数无返回值无工作方式调用 char name[10]; float salary;float allowance; float life; float tel;float utilities;float rent;float due; float health; float fund;1float total; float should; float actual;2)原型void tea_new功能创建新的信息录入参数无返回值无工作方式创建file3)原型void searchmenu;功能查找菜单参数无返回值无工作方式调用void search_id;void search_name;4)原型void search_id;功能查找信息按编号查找参数无返回值整个信息工作方式调用 number5)原型void search_name;功能查找信息按姓名查找参数无返回值整个信息工作方式调用char name6)原型void delete_id功能删除数据按编号删除参数无返回值无工作方式调用 id7)原型 void change_id; 功能改变数据按编号改参数无返回值整个录入信息3.数据结构的设计定义结构体teacher,用于存放教师的信息。

struct teacher{int number; 教师编号char name[10]; 教师姓名float salary; 教师基本工资float allowance; 教师津贴float life; 教师生活补贴float tel; 教师电话费float utilities; 教师水电费float rent; 教师房租float due; 教师所得税float health; 教室卫生费float fund; 教师公积金float total; 教师合计扣款float should; 教师应发工资float actual; 教师实发工资}tea[500];4.算法实现链表是算法的关键。

在添加新的数据时,可以表头插入也可以表尾插入,这两种插入方法决定了其他成员函数数据的处理。

本系统中采取的是表尾插入的方法。

在删除某信息时需要判断数据是在表头,表中还是表尾,如果删除的是在表中,则需要将删除的前后链表连接起来。

统大量运用了链表的5种基本操作:建立链表、链表的插入、删除、输入和查找。

5.程序清单#include<stdio.h>#include<string.h>#include <stdlib.h>#include<conio.h>/*教师工资管理系统结构体定义*/struct teacher{int number;char name[10];float salary;float allowance;float life;float tel;float utilities;float rent;float due;float health;float fund;float total;float should;float actual;}tea[500];int num=0;FILE *fp;void mainmenu();void readfromfile();void writetofile();void show_all();void tea_new ();void searchmenu();void search_id();void search_name();void delete_id();void change_id();void main(){readfromfile();while(1){mainmenu();}}//主菜单void mainmenu(){char choic;system("cls");printf("\t----------------欢迎使用\(^o^)/~-------------------\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**************************************************\n"); printf("\t请输入所需的服务项目序号: \n");choic=getch();switch(choic){case'1':tea_new ();break;case'2':change_id ();break;case'3':delete_id ();break;case'4':searchmenu();break;case'5':writetofile();break;default:mainmenu();}}//从文件导入void readfromfile(){if((fp=fopen("teacher.bin","rb"))==NULL){printf("\n\t教师工资信息文件不存在哟(*/ω╲*)");if((fp=fopen("teacher.bin","wb"))==NULL){printf("\n\t建立失败");exit(0);}else{printf("\n\t教师工资信息文件已建立(~o ̄3 ̄)~");printf("\n\t按回车键进入主菜单");getch();return;}exit(0);}fseek(fp,0,2);if(ftell(fp)>0){rewind(fp);for(num=0;!feof(fp) && fread(&tea[num],sizeof(struct teacher),1,fp);num++);printf("\n\t教师工资信息文件导入成功(* ̄3 ̄)╭");printf("\n\t文件中无任何记录(=@__@=)");printf("\n\t按回车键进入主菜单");getch();return;}}//写入文件void writetofile(){int i;if((fp=fopen("teacher.bin","wb"))==NULL){printf("\n\t打开文件失败(*/ω╲*)");}for(i=0;i<num;i++){if(fwrite(&tea[i],sizeof(struct teacher),1,fp)!=1){printf("\n\t文件写入错误!(>﹏<)\n");}}fclose(fp);printf("\n\t教师工资信息文件已保存");printf("\n\t按任意键退出程序(* ̄ω ̄)\n\t");exit(0);}//添加记录void tea_new(){printf("请输入教师号:");scanf("%d",&tea[num].number);printf("请输入教师姓名:");scanf("%s",tea[num].name);printf("请输入教师基本工资:");scanf("%f",&tea[num].salary);printf("请输入教师的津贴:");scanf("%f",&tea[num].allowance);printf("请输入教师的生活补贴:");scanf("%f",&tea[num].life);printf("请输入教师的电话费:");scanf("%f",&tea[num].tel);printf("请输入教师的水电费:");scanf("%f",&tea[num].utilities);printf("请输入教师的房租:");scanf("%f",&tea[num].rent);printf("请输入教师的所得税:");scanf("%f",&tea[num].due);printf("请输入教师的卫生费:");scanf("%f",&tea[num].health);printf("请输入教师的公积金:");scanf("%f",&tea[num].fund);tea[num].should =tea[num].salary +tea[num].allowance +tea[num].life;tea[num].total=tea[num].tel+tea[num].utilities+tea[num].rent+tea[num].due+tea[num].health+tea[num].fund;tea[num].actual=tea[num].should-tea[num].total;num++;printf("是否继续添加?(Y/N)");if(getch()=='y')tea_new ();return;}//查询菜单void searchmenu(){char choic;system("cls");printf("\n\t------------查询-------------------");printf("\n\t--------[1]显示所有----------------");printf("\n\t--------[2]按编号查询--------------");printf("\n\t--------[3]按姓名查询--------------");printf("\n\t--------[4]返回主菜单--------------");printf("\n\t请选择:\n");choic=getch();switch(choic){case'1':show_all();break;case'2':search_id();break;case'3':search_name();break;case'4':mainmenu();break;}}//显示所有void show_all(){int i;system("cls");if(num!=0){for(i=0;i<num;i++){printf("\n\t编号: %d",tea[i].number);printf("\n\t姓名: %s",tea[i].name);printf("\n\t基本工资: %.5f",tea[i].salary);printf("\n\t津贴: %.5f",tea[i].allowance);printf("\n\t生活补贴: %.5f",tea[i].life);printf("\n\t电话费: %.5f",tea[i].tel);printf("\n\t水电费: %.5f",tea[i].utilities);printf("\n\t房租: %.5f",tea[i].rent);printf("\n\t所得税: %.5f",tea[i].due);printf("\n\t卫生费: %.5f",tea[i].health);printf("\n\t公积金: %.5f",tea[i].fund);printf("\n\t应发工资: %.5f",tea[i].should);printf("\n\t合计扣款: %.5f",tea[i].total);printf("\n\t实发工资: %.5f",tea[i].actual);if(i+1<num){printf("\n\t_____________________");system("pause");}}printf("\n\t*************************************");}elseprintf("\n\t文件中无记录┭┮﹏┭┮");printf("\n\t按回车键回到主菜单");getch();return;}//按编号查询void search_id(){int mark=0;int i,a=0;int id;printf("\n\t请输入编号:");scanf("%d",&id);for(i=0;i<num;i++){if(id==tea[i].number){printf("\n\t******以下是你要查找的教师工资信息******\n");printf("\n\t编号: %d",tea[i].number);printf("\n\t姓名: %s",tea[i].name);printf("\n\t基本工资: %.5f",tea[i].salary);printf("\n\t津贴: %.5f",tea[i].allowance);printf("\n\t生活补贴: %.5f",tea[i].life);printf("\n\t电话费: %.5f",tea[i].tel);printf("\n\t水电费: %.5f",tea[i].utilities);printf("\n\t房租: %.5f",tea[i].rent);printf("\n\t所得税: %.5f",tea[i].due);printf("\n\t卫生费: %.5f",tea[i].health);printf("\n\t公积金: %.5f",tea[i].fund);printf("\n\t应发工资: %.5f",tea[i].should);printf("\n\t合计扣款: %.5f",tea[i].total);printf("\n\t实发工资: %.5f",tea[i].actual);printf("\n\t*************************************");printf("\n\t按回车键回到主菜单");mark++;getch();return;}}if(mark==0){printf("\n\t没有该编号的信息");printf("\n\t按回车键返回主菜单");getch();return;}}//按姓名查询void search_name(){int mark=0;int i,a=0;char name[10];printf("请输入姓名:");scanf("%s",name);for(i=a;i<num;i++){if(strcmp(tea[i].name,name)==0){printf("\n\t******以下是你要查找的教师工资信息******\n");printf("\n\t编号: %d",tea[i].number);printf("\n\t姓名: %s",tea[i].name);printf("\n\t基本工资: %.5f",tea[i].salary);printf("\n\t津贴: %.5f",tea[i].allowance);printf("\n\t生活补贴: %.5f",tea[i].life);printf("\n\t电话费: %.5f",tea[i].tel);printf("\n\t水电费: %.5f",tea[i].utilities);printf("\n\t房租: %.5f",tea[i].rent);printf("\n\t所得税: %.5f",tea[i].due);printf("\n\t卫生费: %.5f",tea[i].health);printf("\n\t公积金: %.5f",tea[i].fund);printf("\n\t应发工资: %.5f",tea[i].should);printf("\n\t合计扣款: %.5f",tea[i].total);printf("\n\t实发工资: %.5f",tea[i].actual);printf("\n\t*************************************");mark++;if((i+1)<num){printf("\t\n是否继续查找相同名字的教师信息:(y/n)");if(getch()=='y'){a=i;continue;}elsereturn;}else{printf("\n\t按回车键返回主菜单");getch();return;}}}if(mark!=0){printf("\n\t没有相同姓名的教师信息记录");printf("\n\t按回车键回到主菜单");getch();return;}else{printf("\n\t没有相同姓名的教师信息记录");printf("\n\t按回车键回到主菜单");getch();return;}}//删除菜单void delete_id(){int i,j;int deletemark=0;int id;printf("\n\t情输入要删除的编号:");scanf("%d",&id);if(num==0){printf("\n\t对不起,文件中无任何教师工资信息记录");printf("\n\t按回车键回到主菜单");getch();return;}for(i=0;i<num;i++){if(id==tea[i].number){printf("\n\t******以下是你要删除的教师工资信息******\n");printf("\n\t编号: %d",tea[i].number);printf("\n\t姓名: %s",tea[i].name);printf("\n\t基本工资: %.5f",tea[i].salary);printf("\n\t津贴: %.5f",tea[i].allowance);printf("\n\t生活补贴: %.5f",tea[i].life);printf("\n\t电话费: %.5f",tea[i].tel);printf("\n\t水电费: %.5f",tea[i].utilities);printf("\n\t房租: %.5f",tea[i].rent);printf("\n\t所得税: %.5f",tea[i].due);printf("\n\t卫生费: %.5f",tea[i].health);printf("\n\t公积金: %.5f",tea[i].fund);printf("\n\t应发工资: %.5f",tea[i].should);printf("\n\t合计扣款: %.5f",tea[i].total);printf("\n\t实发工资: %.5f",tea[i].actual);printf("\n\t是否删除?(y/n)");if(getch()=='y'){for(j=i;j<num-1;j++)tea[j]=tea[j+1];num--;deletemark++;printf("\n\t删除成功");printf("\n\t是否继续删除?(y/n)");if(getch()=='y')delete_id();return;}elsereturn;}continue;}if(deletemark==0){printf("\n\t没有该教师的记录");printf("\n\t是否继续删除?(y/n)");if(getch()=='y')delete_id();}}//修改菜单void change_id(){int a=0,findmark=0;int i;int id;printf("\n\t请输入要修改教师的编号:");scanf("%d",&id);for(i=a;i<num;i++){if(id==tea[i].number){printf("\n\t******以下是你要修改的教师工资信息******\n");findmark++;printf("\n\t编号: %d",tea[i].number);printf("\n\t姓名: %s",tea[i].name);printf("\n\t基本工资: %.5f",tea[i].salary);printf("\n\t津贴: %.5f",tea[i].allowance);printf("\n\t生活补贴: %.5f",tea[i].life);printf("\n\t电话费: %.5f",tea[i].tel);printf("\n\t水电费: %.5f",tea[i].utilities);printf("\n\t房租: %.5f",tea[i].rent);printf("\n\t所得税: %.5f",tea[i].due);printf("\n\t卫生费: %.5f",tea[i].health);printf("\n\t公积金: %.5f",tea[i].fund);printf("\n\t应发工资: %.5f",tea[i].should);printf("\n\t合计扣款: %.5f",tea[i].total);printf("\n\t实发工资: %.5f",tea[i].actual);i=i;break;}else continue;}printf("\n\t请重新输入以下信息:\n");printf("请输入教师号:");scanf("%d",&tea[num].number);printf("请输入教师姓名:");scanf("%s",tea[num].name);printf("请输入教师基本工资:");scanf("%f",&tea[num].salary);printf("请输入教师的津贴:");scanf("%f",&tea[num].allowance);printf("请输入教师的生活补贴:");scanf("%f",&tea[num].life);printf("请输入教师的电话费:");scanf("%f",&tea[num].tel);printf("请输入教师的水电费:");scanf("%f",&tea[num].utilities);printf("请输入教师的房租:");scanf("%f",&tea[num].rent);printf("请输入教师的所得税:");scanf("%f",&tea[num].due);printf("请输入教师的卫生费:");scanf("%f",&tea[num].health);printf("请输入教师的公积金:");scanf("%f",&tea[num].fund);tea[num].should =tea[num].salary +tea[num].allowance +tea[num].life;tea[num].total=tea[num].tel+tea[num].utilities+tea[num].rent+tea[num].due+tea[num].health+tea[num].fund;tea[num].actual=tea[num].should-tea[num].total;printf("\n\t以下是你修改后的教师工资信息:\n");findmark++;printf("\n\t_________________________________");printf("\n\t编号: %d",tea[i].number);printf("\n\t姓名: %s",tea[i].name);printf("\n\t基本工资: %.5f",tea[i].salary);printf("\n\t津贴: %.5f",tea[i].allowance);printf("\n\t生活补贴: %.5f",tea[i].life);printf("\n\t电话费: %.5f",tea[i].tel);printf("\n\t水电费: %.5f",tea[i].utilities);printf("\n\t房租: %.5f",tea[i].rent);printf("\n\t所得税: %.5f",tea[i].due);printf("\n\t卫生费: %.5f",tea[i].health);printf("\n\t公积金: %.5f",tea[i].fund);printf("\n\t应发工资: %.5f",tea[i].should);printf("\n\t合计扣款: %.5f",tea[i].total);printf("\n\t实发工资: %.5f",tea[i].actual);printf("\n\t_________________________________");printf("\n\t按回车键回到主菜单");getch();return;}五.程序运行结果测试六.结论与心得在设计与编写程序的过程中,我捡起了很多自己以前没有注意到的细节,并对一些知识特别是链表的运用有了更好的掌握,巩固了所学,提升了自己的能力。

相关文档
最新文档