中南大学C语言程序设计实验——职工工资管理系统(附详细操作说明及注释)

  • 格式:doc
  • 大小:70.50 KB
  • 文档页数:17

;. ;.' /* Note:Your choice is C IDE */ #include "stdio.h" #include "string.h" #include "conio.h" #include "stdlib.h" struct Message /*此结构体用于存放职工信息以及创建链表*/ { char name[30]; int ID; int JBGZ; int ZWGZ; int JT; int YLBX; int GJJ; long int Total; float Sum_3; struct Message *nextPrt; } static *head,*Rec_1=NULL,*Rec_2=NULL, *Rec_3=NULL; /*此处创建一个表头,以及三个用于恢复函数的静态变量*/ static float Sum_JBGZ=0,Sum_ZWGZ=0,Sum_JT=0,Sum_YLBX=0,Sum_GJJ=0; static float Average_JBGZ,Average_ZWGZ,Average_JT,Average_YLBX,Average_GJJ; void Input(); /*此处声明各一级函数*/ void Output(); void Delete(); void Add(); void Recover(); void Modify(); void Search(); void Statistic(); struct Message *creat(struct Message *h); /*此处声明各二级函数*/ void print_Message(struct Message *h); struct Message *del_Message(struct Message *h,char *str); struct Message *add_Message(struct Message *h,struct Message *a,char *strafter); struct Message *Recover_Message(struct Message *h); struct Message *Modify_Message(struct Message *h,char *str); void Search_Message(struct Message *h); void Statistic_Message(struct Message *h); main() /*主函数为菜单页*/ {char i; /*功能:调用各一级函数一级退出程序*/ ;. ;.' clrscr(); gotoxy(27,9); printf("\16[ 中 南 大 学 ]"); gotoxy(27,11); printf("\16[ 职工工资管理系统 ]"); gotoxy(27,13); printf("\16[ 设 计 者:刘 路 ]"); gotoxy(27,15); printf("\16[ 输入任意键继续 ]\n"); getch(); for(;;) { clrscr(); gotoxy(25,9); printf("* * * * * * *菜单* * * * * *"); gotoxy(25,10); printf("* a. 输入记录 *"); gotoxy(25,11); printf("* b. 显示记录 *"); gotoxy(25,12); printf("* c. 修改记录 *"); gotoxy(25,13); printf("* d. 查找记录 *"); gotoxy(25,14); printf("* e. 添加记录 *"); gotoxy(25,15); printf("* f. 删除记录 *"); gotoxy(25,16); printf("* g. 恢复记录 *"); gotoxy(25,17); printf("* h. 统计数据 *"); gotoxy(25,18); printf("* i. 退出程序 *"); gotoxy(25,19); printf("* 请选择 a—i *"); gotoxy(25,20); printf("* * * * * * * * * * * * * **"); i=getch(); if(i=='i')break; else switch(i) {case'a':Input();break; /*调用记录输入函数*/ case'b':Output();break; /*调用记录显示函数*/ case'c':Modify();break; /*调用记录修改函数*/ ;. ;.' case'd':Search();break; /*调用记录查找函数*/ case'e':Add();break; /*调用记录添加函数*/ case'f':Delete();break; /*调用记录删除函数*/ case'g':Recover();break; /*调用记录恢复函数*/ case'h':Statistic();break; /*调用记录统计函数*/ }}} void Input() /*定义输入函数(一级)*/

{ /*主要功能:调用二级子函数创建链表*/ head=NULL; head=creat(head); } void Output() /*定义显示函数(一级)*/ { /*主要功能:调用二级子函数实现按一定格式输出所有职工工资信息*/ clrscr(); print_Message(head); } void Delete() /*定义删除函数(一级)*/ { /*主要功能:调用二级子函数实现删除任意职工工资信息并输出删除后的工资信息*/ char name[50],*del_Mes=name; clrscr(); gotoxy(1,1); printf("请输入姓名:\n"); scanf("%s",name); head=del_Message(head,del_Mes); clrscr(); printf("删除数据后:\n"); printf("----------------------------------------------------------\n"); print_Message(head); } void Add() /*定义添加函数(一级)*/ { /*主要功能:调用二级函数以实现在任意位置添加一条或多条职工工资信息*/ char after_name[30],i; struct Message* p; clrscr(); gotoxy(1,1); printf("\n请输入需要添加的信息\n"); printf("----------------------------------------------------------\n"); p=(struct Message*)malloc(sizeof (struct Message)); if(p!=NULL) ;. ;.' { printf("请输入姓名:\n"); scanf("%s",&p->name); printf("请输入ID:\n"); scanf("%d",&p->ID); printf("请输入基本工资:\n"); scanf("%d",&p->JBGZ); printf("请输入职位工资:\n"); scanf("%d",&p->ZWGZ); printf("请输入津贴:\n"); scanf("%d",&p->JT); printf("请输入医疗保险:\n"); scanf("%d",&p->YLBX); printf("请输入公积金:\n"); scanf("%d",&p->GJJ); p->Total=p->JBGZ+p->ZWGZ+p->JT-p->YLBX-p->GJJ; printf("总工资为:%d\n",p->Total); } printf("\n输入在哪个职工信息下方添加新信息:\n"); scanf("%s",after_name); head=add_Message(head,p,after_name); printf("\n是否继续添加?Y/N"); i=getch(); while (i!='N') { printf("\n请输入你想要添加的信息\n"); printf("----------------------------------------------------------\n"); p=(struct Message*)malloc(sizeof (struct Message)); if(p!=NULL) { printf("请输入姓名:\n"); scanf("%s",&p->name); printf("请输入ID:\n"); scanf("%d",&p->ID); printf("请输入基本工资:\n"); scanf("%d",&p->JBGZ); printf("请输入职位工资:\n"); scanf("%d",&p->ZWGZ); printf("请输入津贴:\n"); scanf("%d",&p->JT); printf("请输入医疗保险:\n"); scanf("%d",&p->YLBX); printf("请输入公积金:\n");