|
|
|
|
#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 add();
|
|
|
|
|
void menu();
|
|
|
|
|
int n; //Ա<><D4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
struct emploee //ְ<><D6B0><EFBFBD><EFBFBD><EFBFBD>ݽṹ
|
|
|
|
|
{
|
|
|
|
|
char no[5];
|
|
|
|
|
char name[8];
|
|
|
|
|
int wage1; //Ա<><D4B1><EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
int wage2; //Ա<><D4B1><EFBFBD><EFBFBD>ְ<EFBFBD><D6B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
int funds; //Ա<><D4B1><EFBFBD>Ĺ<EFBFBD><C4B9><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
int ylbx; //Ա<><D4B1><EFBFBD><EFBFBD>ҽ<EFBFBD>Ʊ<EFBFBD><C6B1><EFBFBD>
|
|
|
|
|
int jt; //Ա<><D4B1><EFBFBD>Ľ<EFBFBD><C4BD><EFBFBD>
|
|
|
|
|
int wage3; //Ա<><D4B1><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
int wage4; //ǰ3<C7B0><EFBFBD>ʺ<EFBFBD>
|
|
|
|
|
}emp[NUM],newemp;
|
|
|
|
|
int main()
|
|
|
|
|
{
|
|
|
|
|
system("color CF");
|
|
|
|
|
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-----ɾ<><C9BE>ְ<EFBFBD><D6B0><EFBFBD><EFBFBD>Ϣ------ *\n");
|
|
|
|
|
printf("* 4-----<2D><EFBFBD>ְ<EFBFBD><D6B0><EFBFBD><EFBFBD>Ϣ------ *\n");
|
|
|
|
|
printf("* 5-----<2D><><EFBFBD><EFBFBD>ͳ<EFBFBD><CDB3><EFBFBD><EFBFBD>Ϣ------ *\n");
|
|
|
|
|
printf("* 6-----<2D><><EFBFBD><EFBFBD>ְ<EFBFBD><D6B0><EFBFBD><EFBFBD>Ϣ------ *\n");
|
|
|
|
|
printf("* 7-----<2D><><EFBFBD><EFBFBD>ְ<EFBFBD><D6B0><EFBFBD><EFBFBD>Ϣ------ *\n");
|
|
|
|
|
printf("* 8-------<2D>˳<EFBFBD><CBB3><EFBFBD><EFBFBD><EFBFBD>-------- *\n");
|
|
|
|
|
printf("* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:ŷ <20><> <20><> *\n");
|
|
|
|
|
printf("*********************************************\n");
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>1-8<><38>:");
|
|
|
|
|
scanf("%d",&n);
|
|
|
|
|
if(n<1||n>8)
|
|
|
|
|
{
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:\n");
|
|
|
|
|
return menu();
|
|
|
|
|
}
|
|
|
|
|
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:browse(); break;
|
|
|
|
|
case 7:add(); break;
|
|
|
|
|
case 8: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);
|
|
|
|
|
}
|
|
|
|
|
int load()/*<2A><><EFBFBD>뺯<EFBFBD><EBBAAF>int<6E><74>*/
|
|
|
|
|
{
|
|
|
|
|
FILE *fp;
|
|
|
|
|
int i=0;
|
|
|
|
|
if((fp=fopen("emp.txt","rb"))==NULL)
|
|
|
|
|
{
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD>ܴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>\n");
|
|
|
|
|
exit(0);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
fread(&emp[i],sizeof(struct emploee),1,fp);
|
|
|
|
|
i++;
|
|
|
|
|
}while(feof(fp)==0);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
fclose(fp);
|
|
|
|
|
return(i-1);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
void save(int m)//<2F><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>ĺ<EFBFBD><C4BA><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
FILE *fp;//<2F><><EFBFBD><EFBFBD>fp<66><70>ָ<EFBFBD>룬<EFBFBD><EBA3AC><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>FILE<4C><45><EFBFBD>͵Ķ<CDB5><C4B6><EFBFBD>
|
|
|
|
|
if((fp=fopen("emp.txt","wb"))==NULL)//<2F><><EFBFBD><EFBFBD>ְ<EFBFBD><D6B0><EFBFBD>б<EFBFBD><D0B1>ļ<EFBFBD>Ϊ<EFBFBD><CEAA>
|
|
|
|
|
{
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
|
|
|
|
|
exit(0);
|
|
|
|
|
}
|
|
|
|
|
for(i=0;i<m;i++)//<2F><><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD>ְ<EFBFBD><D6B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>ȥ
|
|
|
|
|
if(fwrite(&emp[i],sizeof(struct emploee),1,fp)!=1)//д<><D0B4><EFBFBD><EFBFBD><EFBFBD>ݿ<EFBFBD>
|
|
|
|
|
printf("<EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><EFBFBD><EFBFBD><EFBFBD>!\n");
|
|
|
|
|
fclose(fp); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʣ<EFBFBD><CAA3> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC>У<EFBFBD><D0A3><EFBFBD><EFBFBD>ͷ<EFBFBD><CDB7>ļ<EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD>йصĻ<D8B5><C4BB><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
/*************************<2A><><EFBFBD><EFBFBD>**********************/
|
|
|
|
|
void enter()
|
|
|
|
|
{
|
|
|
|
|
FILE *fp;
|
|
|
|
|
int n,i,j;
|
|
|
|
|
fp=fopen("emp.txt","ab+");
|
|
|
|
|
if(fp==NULL)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
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("%d",&emp[i].wage1);
|
|
|
|
|
printf("ְ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
|
|
|
|
|
scanf("%d",&emp[i].wage2);
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
|
|
|
|
|
scanf("%d",&emp[i].jt);
|
|
|
|
|
printf("ҽ<EFBFBD>Ʊ<EFBFBD><EFBFBD><EFBFBD>:");
|
|
|
|
|
scanf("%d",&emp[i].ylbx);
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
|
|
|
|
|
scanf("%d",&emp[i].funds);
|
|
|
|
|
emp[i].wage3=emp[i].wage1+emp[i].wage2-emp[i].ylbx+emp[i].jt-emp[i].funds;
|
|
|
|
|
emp[i].wage4=emp[i].wage1+emp[i].wage2+emp[i].jt;
|
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
|
float a=0,b=0,c=0;
|
|
|
|
|
if((fp=fopen("emp.txt","rb"))==NULL)
|
|
|
|
|
{
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD>ܴ<EFBFBD><EFBFBD><EFBFBD>emp<EFBFBD>ļ<EFBFBD>\n");
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
|
for(n=0;fread(&emp[n],sizeof(struct emploee),1,fp)!=0;n++)
|
|
|
|
|
{
|
|
|
|
|
if(emp[n].wage4>=2000&&emp[n].wage4<=3000)
|
|
|
|
|
b++;
|
|
|
|
|
else if(emp[n].wage4>0&&emp[n].wage4<=2000)
|
|
|
|
|
c++;
|
|
|
|
|
}
|
|
|
|
|
a=n-b-c;
|
|
|
|
|
printf("ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>֮<EFBFBD><EFBFBD><EFBFBD><EFBFBD>0~2000Ԫ<30><D4AA>ռ<EFBFBD>İٷ<C4B0>֮%.1f\n",c*100/n);
|
|
|
|
|
printf("ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>֮<EFBFBD><EFBFBD><EFBFBD><EFBFBD>2000~3000Ԫ<30><D4AA>ռ<EFBFBD>İٷ<C4B0>֮%.1f\n",b*100/n);
|
|
|
|
|
printf("ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>֮<EFBFBD><EFBFBD><EFBFBD><EFBFBD>3000Ԫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ռ<EFBFBD>İٷ<EFBFBD>֮%.1f\n",a*100/n);
|
|
|
|
|
fclose(fp);
|
|
|
|
|
}
|
|
|
|
|
/********************ɾ<><C9BE><EFBFBD><EFBFBD>Ϣ<EFBFBD>ĵط<C4B5>*******************/
|
|
|
|
|
void dele_num()
|
|
|
|
|
{
|
|
|
|
|
FILE *fp;
|
|
|
|
|
int m=load();
|
|
|
|
|
int i,j,n,t,button;
|
|
|
|
|
char name[20];
|
|
|
|
|
printf("ԭ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ְ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ:\n");
|
|
|
|
|
browse();//<2F><>ʾɾ<CABE><C9BE>ǰ<EFBFBD><C7B0>ְ<EFBFBD><D6B0><EFBFBD><EFBFBD>Ϣ
|
|
|
|
|
printf("\n");
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><EFBFBD>:\n");
|
|
|
|
|
scanf("%s",name);
|
|
|
|
|
for(button=1,i=0;button&&i<m;i++)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7>button==1ʱ<31><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>ſ<EFBFBD><C5BF>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
if(strcmp(emp[i].name,name)==0)//<2F><><EFBFBD>ļ<EFBFBD><C4BC>е<EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ľ<EFBFBD><C4BD>бȽ<D0B1>
|
|
|
|
|
{
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ԭʼ<EFBFBD><EFBFBD>¼:\n");//<2F><>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|
|
|
|
printf("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> <20>ܹ<EFBFBD><DCB9><EFBFBD>\n");
|
|
|
|
|
printf("\n %-6s%-6s %-8d %-8d %-8d %-8d %-8d %-8d",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("\nȷ<EFBFBD><EFBFBD>ɾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>0\n");
|
|
|
|
|
scanf("%d",&n);
|
|
|
|
|
if(n==1)
|
|
|
|
|
{
|
|
|
|
|
for(j=i;j<m;j++)//<2F>ӵ<EFBFBD>i<EFBFBD><69><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ÿһ<C3BF><EFBFBD>滻ǰһ<C7B0><D2BB><EFBFBD><EFBFBD>ֵ
|
|
|
|
|
{
|
|
|
|
|
emp[j]=emp[j+1];
|
|
|
|
|
}
|
|
|
|
|
button=0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
fp=fopen("emp.txt","wb+");
|
|
|
|
|
for(i<0;i<m-1;i++)
|
|
|
|
|
fwrite( &emp[i],sizeof(struct emploee),1,fp);
|
|
|
|
|
fclose(fp);
|
|
|
|
|
if(!button)//button=0<><30>ʾɾ<CABE><C9BE><EFBFBD>ɹ<EFBFBD>
|
|
|
|
|
m=m-1;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
|
|
|
|
|
else
|
|
|
|
|
printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!\n");
|
|
|
|
|
printf("\nɾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ְ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ:\n");
|
|
|
|
|
save(m);//<2F><><EFBFBD>ñ<EFBFBD><C3B1>溯<EFBFBD><E6BAAF>
|
|
|
|
|
browse();//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>0\n");
|
|
|
|
|
scanf("%d",&t);
|
|
|
|
|
switch(t)
|
|
|
|
|
{
|
|
|
|
|
case 1:dele_num();break;
|
|
|
|
|
case 0:break;
|
|
|
|
|
default:break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/********************<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>ID:");
|
|
|
|
|
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);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
printf("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> <20>ܹ<EFBFBD><DCB9><EFBFBD>\n");
|
|
|
|
|
printf("%-6s %-6s %-8d %-8d %-8d %-8d %-8d %-8d\n",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("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> <20>ܹ<EFBFBD><DCB9><EFBFBD>\n");
|
|
|
|
|
scanf("%s%s%d%d%d%d%d",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("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> <20>ܹ<EFBFBD><DCB9><EFBFBD>\n");
|
|
|
|
|
for(i=0;fread(&emp[i],sizeof(struct emploee),1,fp)!=0;i++)
|
|
|
|
|
printf(" %-6s %-6s %-8d %-8d %-8d %-8d %-8d %-8d\n",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,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>ѯ<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");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
printf("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> <20>ܹ<EFBFBD><DCB9><EFBFBD>\n");
|
|
|
|
|
printf("%-6s %-6s %-8d %-8d %-8d %-8d %-8d %-8d\n",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>밴1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>밴0\n");
|
|
|
|
|
scanf("%d",&n);
|
|
|
|
|
switch(n)
|
|
|
|
|
{
|
|
|
|
|
case 1:search_num();break;
|
|
|
|
|
case 0:break;
|
|
|
|
|
default:break;
|
|
|
|
|
}
|
|
|
|
|
fclose(fp);
|
|
|
|
|
}
|
|
|
|
|
/*******************<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD>ĵط<C4B5>********************/
|
|
|
|
|
void browse()
|
|
|
|
|
{ int i,sum=0;
|
|
|
|
|
int m=load();
|
|
|
|
|
float pjwage1=0,pjwage2=0,pjylbx=0;
|
|
|
|
|
int pjjt=0,pjfunds=0;
|
|
|
|
|
printf("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> <20>ܹ<EFBFBD><DCB9><EFBFBD>\n");
|
|
|
|
|
for(i=0;i<m;i++)
|
|
|
|
|
{
|
|
|
|
|
printf("%-6s%-6s %-8d %-8d %-8d %-8d %-8d %-8d\n",emp[i].no,
|
|
|
|
|
emp[i].name,emp[i].wage1,emp[i].wage2,emp[i].jt,emp[i].ylbx,emp[i].funds,emp[i].wage3);
|
|
|
|
|
sum=emp[i].wage1+emp[i].wage2+emp[i].jt;//<2F><><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܺ<EFBFBD>
|
|
|
|
|
printf("ǰ3<EFBFBD><EFBFBD><EFBFBD>֮<EFBFBD><EFBFBD> %d\n",sum);
|
|
|
|
|
pjwage1+=emp[i].wage1;pjwage2+=emp[i].wage2;pjjt+=emp[i].jt;pjylbx+=emp[i].ylbx;pjfunds+=emp[i].funds;
|
|
|
|
|
}
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: %.1f %.1f %d %.1f %d\n",pjwage1/m,pjwage2/m,pjjt/m,pjylbx/m,pjfunds/m);
|
|
|
|
|
}
|
|
|
|
|
/******************<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ*******************/
|
|
|
|
|
void add()
|
|
|
|
|
{
|
|
|
|
|
FILE *fp;
|
|
|
|
|
int n,i,t;
|
|
|
|
|
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++) /* ѭ<><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("%d",&emp[i].wage1);
|
|
|
|
|
printf("ְ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
|
|
|
|
|
scanf("%d",&emp[i].wage2);
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
|
|
|
|
|
scanf("%d",&emp[i].jt);
|
|
|
|
|
printf("ҽ<EFBFBD>Ʊ<EFBFBD><EFBFBD><EFBFBD>:");
|
|
|
|
|
scanf("%d",&emp[i].ylbx);
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
|
|
|
|
|
scanf("%d",&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);
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>밴1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>밴0\n");
|
|
|
|
|
scanf("%d",&t);
|
|
|
|
|
switch(t)
|
|
|
|
|
{
|
|
|
|
|
case 1:add();break;
|
|
|
|
|
case 0:break;
|
|
|
|
|
default:break;
|
|
|
|
|
}
|
|
|
|
|
fclose(fp);
|
|
|
|
|
}
|