|
|
|
|
#include<stdio.h>
|
|
|
|
|
#include<string.h>
|
|
|
|
|
#include<stdlib.h>
|
|
|
|
|
#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; //Ա<><D4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
struct emploee //ְ<><D6B0><EFBFBD><EFBFBD><EFBFBD>ݽṹ
|
|
|
|
|
{
|
|
|
|
|
char no[5];
|
|
|
|
|
char name[8];
|
|
|
|
|
float wage1; //Ա<><D4B1><EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
float wage2; //Ա<><D4B1><EFBFBD><EFBFBD>ְ<EFBFBD><D6B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
float funds; //Ա<><D4B1><EFBFBD>Ĺ<EFBFBD><C4B9><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
float ylbx; //Ա<><D4B1><EFBFBD><EFBFBD>ҽ<EFBFBD>Ʊ<EFBFBD><C6B1><EFBFBD>
|
|
|
|
|
float jt; //Ա<><D4B1><EFBFBD>Ľ<EFBFBD><C4BD><EFBFBD>
|
|
|
|
|
float wage3; //Ա<><D4B1><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
}emp[NUM],newemp;
|
|
|
|
|
int main()
|
|
|
|
|
{
|
|
|
|
|
menu();
|
|
|
|
|
}
|
|
|
|
|
void menu()//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
int n;
|
|
|
|
|
do{
|
|
|
|
|
printf("************* ְ<><D6B0><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD>ϵͳ **************\n");
|
|
|
|
|
printf("* 1-----<2D><><EFBFBD><EFBFBD>ְ<EFBFBD><D6B0><EFBFBD><EFBFBD>Ϣ------ *\n");
|
|
|
|
|
printf("* 2-----<2D><>ѯְ<D1AF><D6B0><EFBFBD><EFBFBD>Ϣ------ *\n");
|
|
|
|
|
printf("* 3-----<2D><><EFBFBD><EFBFBD>ְ<EFBFBD><D6B0>ID<49><44>ɾ<EFBFBD><C9BE>-- *\n");
|
|
|
|
|
printf("* 4-----<2D><><EFBFBD><EFBFBD>ְ<EFBFBD><D6B0>ID<49><44><EFBFBD><EFBFBD>-- *\n");
|
|
|
|
|
printf("* 5-----<2D>ݹ<EFBFBD><DDB9><EFBFBD>ͳ<EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD><EFBFBD><EFBFBD>-- *\n");
|
|
|
|
|
printf("* 6-----<2D><><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ---- *\n");
|
|
|
|
|
printf("* 7-----<2D><><EFBFBD><EFBFBD>ȫ<EFBFBD><C8AB>ְ<EFBFBD><D6B0><EFBFBD><EFBFBD>Ϣ-- *\n");
|
|
|
|
|
printf("* 8-----<2D><><EFBFBD><EFBFBD>ְ<EFBFBD><D6B0><EFBFBD><EFBFBD>Ϣ------ *\n");
|
|
|
|
|
printf("* 9-----<2D>˳<EFBFBD><CBB3><EFBFBD><EFBFBD><EFBFBD>---------- *\n");
|
|
|
|
|
printf("*********************************************\n");
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>1-9<><39>:");
|
|
|
|
|
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;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><D8B5><EFBFBD>Ϣ
|
|
|
|
|
case 7:browse(); break;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|
|
|
|
case 8:add(); break;
|
|
|
|
|
case 9:printf("*******<2A><>ӭ<EFBFBD>´<EFBFBD>ʹ<EFBFBD>ã<EFBFBD>*******");
|
|
|
|
|
default:exit(0);//<2F>˳<EFBFBD>ϵͳ.exit(0)<29><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD><CBB3><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
}while(n!=0);
|
|
|
|
|
}
|
|
|
|
|
/*************************<2A><>ʼ<EFBFBD>ĵط<C4B5>**********************/
|
|
|
|
|
void enter()
|
|
|
|
|
{
|
|
|
|
|
FILE *fp;
|
|
|
|
|
int n,i;
|
|
|
|
|
if ((fp=fopen("emp.txt","wb"))==NULL)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD>ܽ<EFBFBD><EFBFBD><EFBFBD>emp<EFBFBD>ļ<EFBFBD>\n");
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ְ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
|
|
|
|
|
scanf("%d",&n);
|
|
|
|
|
for(i=0;i<n;i++) /* ѭ<><D1AD><EFBFBD><EFBFBD>ȡn<C8A1><6E>ְ<EFBFBD><D6B0><EFBFBD><EFBFBD>¼ */
|
|
|
|
|
{
|
|
|
|
|
printf("<EFBFBD><EFBFBD>%d<><64>ְ<EFBFBD><D6B0>:\n",i+1);
|
|
|
|
|
printf("ID:");
|
|
|
|
|
scanf("%s",emp[i].no);
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
|
|
|
|
|
scanf("%s",&emp[i].name);
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
|
|
|
|
|
scanf("%f",&emp[i].wage1);
|
|
|
|
|
printf("ְ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
|
|
|
|
|
scanf("%f",&emp[i].wage2);
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
|
|
|
|
|
scanf("%f",&emp[i].jt);
|
|
|
|
|
printf("ҽ<EFBFBD>Ʊ<EFBFBD><EFBFBD><EFBFBD>:");
|
|
|
|
|
scanf("%f",&emp[i].ylbx);
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
|
|
|
|
|
scanf("%f",&emp[i].funds);
|
|
|
|
|
emp[i].wage3=emp[i].wage1+emp[i].wage2-emp[i].ylbx+emp[i].jt-emp[i].funds;
|
|
|
|
|
}
|
|
|
|
|
for(i=0;i<n;i++) /*<2A><>n<EFBFBD><6E>ְ<EFBFBD><D6B0><EFBFBD><EFBFBD>¼д<C2BC><D0B4><EFBFBD>ļ<EFBFBD>*/
|
|
|
|
|
fwrite(&emp[i],sizeof(struct emploee),1,fp);
|
|
|
|
|
fclose(fp);
|
|
|
|
|
}
|
|
|
|
|
/*************************ͳ<><CDB3><EFBFBD><EFBFBD>Ϣ**********************/
|
|
|
|
|
void count()
|
|
|
|
|
{
|
|
|
|
|
FILE *fp;
|
|
|
|
|
int n,num;
|
|
|
|
|
if((fp=fopen("emp.txt","rb"))==NULL)
|
|
|
|
|
{
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD>ܴ<EFBFBD><EFBFBD><EFBFBD>emp<EFBFBD>ļ<EFBFBD>\n");
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>빤<EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
|
|
|
|
|
scanf("%d",&num);
|
|
|
|
|
printf("<EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD> ID <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ְ<><D6B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> ҽ<>Ʊ<EFBFBD><C6B1><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
|
|
|
|
|
for(n=0;fread(&emp[n],sizeof(struct emploee),1,fp)!=0;n++)
|
|
|
|
|
if(emp[n].wage3>=num)
|
|
|
|
|
{
|
|
|
|
|
printf("<EFBFBD><EFBFBD>%d<><64>ְ<EFBFBD><D6B0>:\n",n+1);
|
|
|
|
|
printf("ID:");
|
|
|
|
|
scanf("%s",emp[n].no);
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
|
|
|
|
|
scanf("%s",&emp[n].name);
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
|
|
|
|
|
scanf("%f",&emp[n].wage1);
|
|
|
|
|
printf("ְ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
|
|
|
|
|
scanf("%f",&emp[n].wage2);
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
|
|
|
|
|
scanf("%f",&emp[n].jt);
|
|
|
|
|
printf("ҽ<EFBFBD>Ʊ<EFBFBD><EFBFBD><EFBFBD>:");
|
|
|
|
|
scanf("%f",&emp[n].ylbx);
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
|
|
|
|
|
scanf("%f",&emp[n].funds);
|
|
|
|
|
printf("<EFBFBD>ܹ<EFBFBD><EFBFBD><EFBFBD>:");
|
|
|
|
|
scanf("%f",&emp[n].wage3);
|
|
|
|
|
}
|
|
|
|
|
fclose(fp);
|
|
|
|
|
}
|
|
|
|
|
/********************ɾ<><C9BE><EFBFBD><EFBFBD>Ϣ<EFBFBD>ĵط<C4B5>*******************/
|
|
|
|
|
void dele_num()
|
|
|
|
|
{
|
|
|
|
|
FILE *fp;
|
|
|
|
|
int i,j,n;
|
|
|
|
|
char num[5];
|
|
|
|
|
if((fp=fopen("emp.txt","rb"))==NULL)
|
|
|
|
|
{
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD>ܴ<EFBFBD><EFBFBD><EFBFBD>emp<EFBFBD>ļ<EFBFBD>\n");
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
|
printf("ɾ<EFBFBD><EFBFBD>ǰ:\n");
|
|
|
|
|
printf("<EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD> ID <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ְ<><D6B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> ҽ<>Ʊ<EFBFBD><C6B1><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
|
|
|
|
|
for(n=0;fread(&emp[n],sizeof(struct emploee),1,fp);n++)
|
|
|
|
|
{
|
|
|
|
|
printf("<EFBFBD><EFBFBD>%d<><64>ְ<EFBFBD><D6B0>:\n",n+1);
|
|
|
|
|
printf("ID:");
|
|
|
|
|
scanf("%s",emp[i].no);
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
|
|
|
|
|
scanf("%s",&emp[i].name);
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
|
|
|
|
|
scanf("%f",&emp[i].wage1);
|
|
|
|
|
printf("ְ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
|
|
|
|
|
scanf("%f",&emp[i].wage2);
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
|
|
|
|
|
scanf("%f",&emp[i].jt);
|
|
|
|
|
printf("ҽ<EFBFBD>Ʊ<EFBFBD><EFBFBD><EFBFBD>:");
|
|
|
|
|
scanf("%f",&emp[i].ylbx);
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
|
|
|
|
|
scanf("%f",&emp[i].funds);
|
|
|
|
|
printf("<EFBFBD>ܹ<EFBFBD><EFBFBD><EFBFBD>:");
|
|
|
|
|
scanf("%f",&emp[i].wage3);
|
|
|
|
|
}/*nΪemp<6D>ļ<EFBFBD><C4BC>м<EFBFBD>¼<EFBFBD><C2BC>*/
|
|
|
|
|
printf("Ҫɾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ְ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
|
|
|
|
|
scanf("%s",num);
|
|
|
|
|
for(i=0;(strcmp(emp[i].no,num)!=0&&i<n);i++)
|
|
|
|
|
if(i>=n)
|
|
|
|
|
{
|
|
|
|
|
printf("\tû<EFBFBD><EFBFBD>%sְ<73><D6B0><EFBFBD>ŵ<EFBFBD>ְ<EFBFBD><D6B0>\n",num);
|
|
|
|
|
exit(2);
|
|
|
|
|
}
|
|
|
|
|
fclose(fp);
|
|
|
|
|
fp=fopen("emp.dat","w+");
|
|
|
|
|
if(n==1) /*һ<><D2BB><EFBFBD><EFBFBD>¼<EFBFBD>Ѿ<EFBFBD>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD>*/
|
|
|
|
|
{
|
|
|
|
|
fclose(fp);
|
|
|
|
|
exit(3);
|
|
|
|
|
}
|
|
|
|
|
for(j=0;j<i;j++)
|
|
|
|
|
fwrite(&emp[j],sizeof(struct emploee),1,fp);
|
|
|
|
|
for(j=i+1;j<n;j++)
|
|
|
|
|
fwrite(&emp[j],sizeof(struct emploee),1,fp);
|
|
|
|
|
printf("ɾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>:\n");
|
|
|
|
|
fseek(fp,0,SEEK_SET);
|
|
|
|
|
for(i=0;fread(&emp[i],sizeof(struct emploee),1,fp);i++)
|
|
|
|
|
{
|
|
|
|
|
printf("<EFBFBD><EFBFBD>%d<><64>ְ<EFBFBD><D6B0>:\n",i+1);
|
|
|
|
|
printf("ID:");
|
|
|
|
|
scanf("%s",emp[i].no);
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
|
|
|
|
|
scanf("%s",&emp[i].name);
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
|
|
|
|
|
scanf("%f",&emp[i].wage1);
|
|
|
|
|
printf("ְ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
|
|
|
|
|
scanf("%f",&emp[i].wage2);
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
|
|
|
|
|
scanf("%f",&emp[i].jt);
|
|
|
|
|
printf("ҽ<EFBFBD>Ʊ<EFBFBD><EFBFBD><EFBFBD>:");
|
|
|
|
|
scanf("%f",&emp[i].ylbx);
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
|
|
|
|
|
scanf("%f",&emp[i].funds);
|
|
|
|
|
printf("<EFBFBD>ܹ<EFBFBD><EFBFBD><EFBFBD>:");
|
|
|
|
|
scanf("%f",&emp[i].wage3);
|
|
|
|
|
}
|
|
|
|
|
fclose(fp);
|
|
|
|
|
}
|
|
|
|
|
/********************<2A><EFBFBD><DEB8><EFBFBD>Ϣ<EFBFBD>ĵط<C4B5>*******************/
|
|
|
|
|
void modi_num()
|
|
|
|
|
{
|
|
|
|
|
FILE *fp;
|
|
|
|
|
int i,j;
|
|
|
|
|
char num[5];
|
|
|
|
|
if((fp=fopen("emp.txt","rb+"))==NULL)
|
|
|
|
|
{
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>emp<6D>ļ<EFBFBD>\n");
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
|
printf("Ҫ<EFBFBD>ĵ<EFBFBD>ְ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
|
|
|
|
|
scanf("%s",num);
|
|
|
|
|
for(i=0;fread(&emp[i],sizeof(struct emploee),1,fp);i++)
|
|
|
|
|
if(!strcmp(emp[i].no,num))break;
|
|
|
|
|
if(feof(fp))
|
|
|
|
|
{
|
|
|
|
|
printf("\tû<EFBFBD><EFBFBD>%sְ<73><D6B0><EFBFBD>ŵ<EFBFBD>ְ<EFBFBD><D6B0>\n",num);
|
|
|
|
|
exit(2);
|
|
|
|
|
}
|
|
|
|
|
printf("<EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD> ְ<><D6B0><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ְ<><D6B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> ҽ<>Ʊ<EFBFBD><C6B1><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
|
|
|
|
|
printf("%6d %6s %9s %.1f %.1f %.1f %.1f %.1f %.1f\n",i+1,emp[i].no,emp[i].name,emp[i].wage1,emp[i].wage2,emp[i].jt,emp[i].ylbx,emp[i].funds,emp[i].wage3);
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ:ְ<><D6B0><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ְ<><D6B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> ҽ<>Ʊ<EFBFBD><C6B1><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
|
|
|
|
|
printf("<EFBFBD><EFBFBD>%d<><64><EFBFBD><EFBFBD>¼:",i+1);
|
|
|
|
|
scanf("%s%s%f%f%f%f%f",newemp.no,newemp.name,&newemp.wage1,&newemp.wage2,&newemp.jt,&newemp.ylbx,&newemp.funds);//<2F><>ȡ<EFBFBD>µ<EFBFBD>ְ<EFBFBD><D6B0><EFBFBD><EFBFBD>¼
|
|
|
|
|
newemp.wage3=newemp.wage1+newemp.wage2+newemp.jt-newemp.ylbx-newemp.funds;
|
|
|
|
|
fseek(fp,-(long)sizeof(struct emploee),SEEK_CUR); //<2F>ļ<EFBFBD>ָ<EFBFBD><D6B8>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD>ĵļ<C4B5>¼<EFBFBD><C2BC>ͷ
|
|
|
|
|
fwrite(&newemp,sizeof(struct emploee),1,fp); //<2F><>newemp<6D><70><EFBFBD>ǵ<EFBFBD>ǰ<EFBFBD><C7B0>¼
|
|
|
|
|
printf(" <20>ĺ<DEB8>:\n");
|
|
|
|
|
fseek(fp,0,SEEK_SET); //<2F><>ʾ<EFBFBD>ĺ<DEB8><C4BA><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
printf("<EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD> ְ<><D6B0><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ְ<><D6B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> ҽ<>Ʊ<EFBFBD><C6B1><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
|
|
|
|
|
for(i=0;fread(&emp[i],sizeof(struct emploee),1,fp)!=0;i++)
|
|
|
|
|
printf("%6d %6s %9s %.1f %.1f %.1f %.1f %.1f %.1f\n",i+1,emp[i].no,emp[i].name,emp[i].wage1,emp[i].wage2,emp[i].jt,emp[i].ylbx,emp[i].funds,emp[i].wage3);
|
|
|
|
|
fclose(fp);
|
|
|
|
|
}
|
|
|
|
|
/*************************<2A><>ѯ<EFBFBD><D1AF>Ϣ<EFBFBD>ĵط<C4B5>***********************/
|
|
|
|
|
void search_num()
|
|
|
|
|
{
|
|
|
|
|
FILE *fp;
|
|
|
|
|
int i;
|
|
|
|
|
char num[5];
|
|
|
|
|
if((fp=fopen("emp.txt","rb"))==NULL)
|
|
|
|
|
{
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD>ܴ<EFBFBD><EFBFBD><EFBFBD>emp<EFBFBD>ļ<EFBFBD>\n");
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
|
printf("Ҫ<EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD>ְ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
|
|
|
|
|
scanf("%s",num);
|
|
|
|
|
for(i=0;fread(&emp[i],sizeof(struct emploee),1,fp);i++)
|
|
|
|
|
if(!strcmp(emp[i].no,num)) break;
|
|
|
|
|
if(feof(fp))
|
|
|
|
|
{
|
|
|
|
|
printf("\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
|
|
|
|
|
exit(2);
|
|
|
|
|
}
|
|
|
|
|
printf("<EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD> ְ<><D6B0><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ְ<><D6B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> ҽ<>Ʊ<EFBFBD><C6B1><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
|
|
|
|
|
printf("%6d %6s %9s %.1f %.1f %.1f %.1f %.1f %.1f\n",i+1,emp[i].no,emp[i].name,emp[i].wage1,emp[i].wage2,emp[i].jt,emp[i].ylbx,emp[i].funds,emp[i].wage3);
|
|
|
|
|
fclose(fp);
|
|
|
|
|
}
|
|
|
|
|
/*******************<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD>ĵط<C4B5>********************/
|
|
|
|
|
void browse()
|
|
|
|
|
{ int i;
|
|
|
|
|
FILE *fp;
|
|
|
|
|
if((fp=fopen("emp.txt","r"))==NULL)
|
|
|
|
|
{
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD>ܴ<EFBFBD><EFBFBD><EFBFBD>emp<EFBFBD>ļ<EFBFBD>\n");
|
|
|
|
|
exit(0);
|
|
|
|
|
}
|
|
|
|
|
printf("<EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD> ְ<><D6B0><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ְ<><D6B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> ҽ<>Ʊ<EFBFBD><C6B1><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
|
|
|
|
|
for(i=0;fread(&emp[i],sizeof(struct emploee),1,fp)!=0;i++)
|
|
|
|
|
{
|
|
|
|
|
printf("%6d %6s %9s %.1f %.1f %.1f %.1f %.1f %.1f\n",i+1,emp[i].no,emp[i].name,emp[i].wage1,emp[i].wage2,emp[i].jt,emp[i].ylbx,emp[i].funds,emp[i].wage3);
|
|
|
|
|
}
|
|
|
|
|
fclose(fp);
|
|
|
|
|
}
|
|
|
|
|
/******************<><D7B7><EFBFBD><EFBFBD>Ϣ<EFBFBD>ĵط<C4B5>*******************/
|
|
|
|
|
void add()
|
|
|
|
|
{
|
|
|
|
|
FILE *fp;
|
|
|
|
|
int n,i,j;
|
|
|
|
|
if((fp=fopen("emp.txt","ab+"))==NULL)
|
|
|
|
|
{
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD>ܴ<EFBFBD><EFBFBD><EFBFBD>emp<EFBFBD>ļ<EFBFBD>\n");
|
|
|
|
|
exit(0);
|
|
|
|
|
}
|
|
|
|
|
printf("Ҫ<EFBFBD>ӵ<EFBFBD>ְ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
|
|
|
|
|
scanf("%d",&n);
|
|
|
|
|
for(i=0;i<n;i++)
|
|
|
|
|
{
|
|
|
|
|
printf("ְ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ְ<><D6B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> ҽ<>Ʊ<EFBFBD><C6B1><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
|
|
|
|
|
printf("<EFBFBD>Ӽ<EFBFBD>¼:\n");
|
|
|
|
|
scanf("%s%s%f%f%f%f%f",newemp.no,newemp.name,&newemp.wage1,&newemp.wage2,&newemp.jt,&newemp.ylbx,&newemp.funds );
|
|
|
|
|
newemp.wage3=newemp.wage1+newemp.wage2-newemp.funds+newemp.jt-newemp.ylbx;//<2F><>ȡһ<C8A1><D2BB><EFBFBD>µ<EFBFBD>ְ<EFBFBD><D6B0><EFBFBD><EFBFBD>¼
|
|
|
|
|
fwrite(&newemp,sizeof(struct emploee),1,fp); //<2F><><EFBFBD><EFBFBD>ְ<EFBFBD><D6B0><EFBFBD><EFBFBD>¼д<C2BC><D0B4><EFBFBD>ļ<EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
fclose(fp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*************************<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD>ĵط<C4B5>**********************/
|
|
|
|
|
void load() //<2F><><EFBFBD>ؼ<EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD>ĺ<EFBFBD><C4BA><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
FILE *fp;
|
|
|
|
|
int i,w;
|
|
|
|
|
w=1;
|
|
|
|
|
system( "cls" );
|
|
|
|
|
if((fp=fopen("emp.txt","rb"))==NULL) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ,<2C>ڴ<EFBFBD>ǰ<EFBFBD>ļ<EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
printf("\nCannot open file\n");
|
|
|
|
|
w=0;
|
|
|
|
|
return ;
|
|
|
|
|
}
|
|
|
|
|
n=0;
|
|
|
|
|
for(i=0;!feof(fp);i++)
|
|
|
|
|
{
|
|
|
|
|
fread(&emp[i],sizeof(struct emploee),1,fp);
|
|
|
|
|
n++;
|
|
|
|
|
}
|
|
|
|
|
n=n-1;
|
|
|
|
|
fclose(fp);
|
|
|
|
|
if(w==1)
|
|
|
|
|
{
|
|
|
|
|
printf("Load file ok!");
|
|
|
|
|
getchar();
|
|
|
|
|
getchar();
|
|
|
|
|
menu();
|
|
|
|
|
}
|
|
|
|
|
}
|