commit cbeebf36e47c959414b47440728502cb601563e2 Author: unknown <2893206723@qq.com> Date: Wed Jan 9 18:22:53 2019 +0800 first commit diff --git a/职工工资管理系统.c b/职工工资管理系统.c new file mode 100644 index 0000000..e66cac1 --- /dev/null +++ b/职工工资管理系统.c @@ -0,0 +1,336 @@ +#include +#include +#include +#define NUM 1000 +void enter(); +void search_num(); +void dele_num(); +void modi_num(); +void browse(); +void count(); +void load(); +void add(); +void menu(); +int n; //Ա +struct emploee //ְݽṹ +{ + char no[5]; + char name[8]; + float wage1; //ԱĻ + float wage2; //Աְ + float funds; //ԱĹ + float ylbx; //ԱҽƱ + float jt; //ԱĽ + float wage3; //Աʵ +}emp[NUM],newemp; +int main() +{ + menu(); +} +void menu()// +{ + int n; +do{ + printf("************* ְʹϵͳ **************\n"); + printf("* 1-----ְϢ------ *\n"); + printf("* 2-----ѯְϢ------ *\n"); + printf("* 3-----ְIDɾ-- *\n"); + printf("* 4-----ְID޸-- *\n"); + printf("* 5-----ݹͳƲ-- *\n"); + printf("* 6-----ļϢ---- *\n"); + printf("* 7-----ȫְϢ-- *\n"); + printf("* 8-----ְϢ------ *\n"); + printf("* 9-----˳---------- *\n"); + printf("*********************************************\n"); + printf("ѡ1-9:"); +scanf("%d",&n); +switch(n) +{ + case 1:enter(); break; + case 2:search_num(); break; + case 3:dele_num(); break; + case 4:modi_num(); break; + case 5:count(); break; + case 6:load(); break;//صϢ + case 7:browse(); break;//Ϣ + case 8:add(); break; + case 9:printf("*******ӭ´ʹã*******"); + default:exit(0);//˳ϵͳ.exit(0)˳ + } +}while(n!=0); +} +/*************************ʼĵط**********************/ +void enter() +{ + FILE *fp; + int n,i; + if ((fp=fopen("emp.txt","wb"))==NULL) + { + + printf("ܽempļ\n"); + exit(1); + } + printf("ְ:"); + scanf("%d",&n); + for(i=0;i=num) + { + printf("%dְ:\n",n+1); + printf("ID:"); + scanf("%s",emp[n].no); + printf(":"); + scanf("%s",&emp[n].name); + printf(":"); + scanf("%f",&emp[n].wage1); + printf("ְ:"); + scanf("%f",&emp[n].wage2); + printf(":"); + scanf("%f",&emp[n].jt); + printf("ҽƱ:"); + scanf("%f",&emp[n].ylbx); + printf(":"); + scanf("%f",&emp[n].funds); + printf("ܹ:"); + scanf("%f",&emp[n].wage3); + } + fclose(fp); +} +/********************ɾϢĵط*******************/ +void dele_num() +{ + FILE *fp; + int i,j,n; + char num[5]; + if((fp=fopen("emp.txt","rb"))==NULL) + { + printf("ܴempļ\n"); + exit(1); + } + printf("ɾǰ:\n"); + printf("¼ ID ְ ҽƱ ʵ\n"); + for(n=0;fread(&emp[n],sizeof(struct emploee),1,fp);n++) + { + printf("%dְ:\n",n+1); + printf("ID:"); + scanf("%s",emp[i].no); + printf(":"); + scanf("%s",&emp[i].name); + printf(":"); + scanf("%f",&emp[i].wage1); + printf("ְ:"); + scanf("%f",&emp[i].wage2); + printf(":"); + scanf("%f",&emp[i].jt); + printf("ҽƱ:"); + scanf("%f",&emp[i].ylbx); + printf(":"); + scanf("%f",&emp[i].funds); + printf("ܹ:"); + scanf("%f",&emp[i].wage3); + }/*nΪempļм¼*/ + printf("Ҫɾְ:"); + scanf("%s",num); + for(i=0;(strcmp(emp[i].no,num)!=0&&i=n) + { + printf("\tû%sְŵְ\n",num); + exit(2); + } + fclose(fp); + fp=fopen("emp.dat","w+"); + if(n==1) /*һ¼Ѿɾ*/ + { + fclose(fp); + exit(3); + } + for(j=0;j