You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
xiongshiheng_001/职工工资管理系统.cpp

349 lines
8.1 KiB

6 years ago
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct worker
{
char name[30];
char id[10];
int salary1,salary2,salary3;
};
int read(struct worker wo[]); //<2F><>ȡ
int show(); //<2F>˵<EFBFBD>
int baocun(struct worker wo[]); //<2F><><EFBFBD><EFBFBD>
int add(); //<2F><><EFBFBD><EFBFBD>
int see(); //<2F>
int search(); //<2F><><EFBFBD><EFBFBD>
int ghcz(); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int xmcz(); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int del(); // ɾ<><C9BE>
int xmsc(); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE>
int ghsc(); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE>
int salary(); //нˮͳ<CBAE><CDB3>
int modify(); //<2F>޸<EFBFBD>
int ghxg(); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸<EFBFBD>
6 years ago
int xmxg(); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸<EFBFBD>
6 years ago
int back();
6 years ago
struct worker wo[100]; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ְ<EFBFBD><D6B0><EFBFBD><EFBFBD>Ϣ
int number=0; //<2F><>¼<EFBFBD>ܵ<EFBFBD>ְ<EFBFBD><D6B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
6 years ago
int main()
{
int choose=0;
while(true)
{
show();
printf("\t\t===><3E><>ѡ<EFBFBD><D1A1>");
scanf("%d",&choose);
system("cls"); //<2F><><EFBFBD><EFBFBD>
switch(choose)
{
case 1: add();back(); break; //<2F><><EFBFBD><EFBFBD>ְ<EFBFBD><D6B0><EFBFBD><EFBFBD>Ϣ
case 2: see();back(); break; //<2F>鿴ְ<E9BFB4><D6B0><EFBFBD><EFBFBD>Ϣ
case 3: search();back(); break; //<2F><><EFBFBD><EFBFBD>ְ<EFBFBD><D6B0><EFBFBD><EFBFBD>Ϣ
case 4: del();back(); break; //ɾ<><C9BE>ְ<EFBFBD><D6B0><EFBFBD><EFBFBD>Ϣ
case 5: salary();back(); break; //ְ<><D6B0>нˮ
case 6: modify();back(); break; //<2F>޸<EFBFBD>ְ<EFBFBD><D6B0><EFBFBD><EFBFBD>Ϣ
default: break;
}
fflush(stdin); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EBBBBA><EFBFBD><EFBFBD>
getchar();
system("cls");
}
}
int read(struct worker wo[])
{
FILE *fp=NULL;
int i=0;
fp=fopen("C:worker.dat","rb");
while(fread(&wo[i],sizeof(struct worker),1,fp))
i++;
fclose(fp);
return i;
}
int show()
{
printf("\n");
printf("\t****************ְ<><D6B0><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD>ϵͳ****************\n");
printf("\t################################################\n");
printf("\t^^^^^^^^^^^^^^^^[1] <20><><EFBFBD><EFBFBD>ְ<EFBFBD><D6B0><EFBFBD><EFBFBD>Ϣ^^^^^^^^^^^^^^^^\n");
printf("\t^^^^^^^^^^^^^^^^[2] <20>鿴ְ<E9BFB4><D6B0><EFBFBD><EFBFBD>Ϣ^^^^^^^^^^^^^^^^\n");
printf("\t^^^^^^^^^^^^^^^^[3] <20><><EFBFBD><EFBFBD>ְ<EFBFBD><D6B0><EFBFBD><EFBFBD>Ϣ^^^^^^^^^^^^^^^^\n");
printf("\t^^^^^^^^^^^^^^^^[4] ɾ<><C9BE>ְ<EFBFBD><D6B0><EFBFBD><EFBFBD>Ϣ^^^^^^^^^^^^^^^^\n");
printf("\t^^^^^^^^^^^^^^^^[5] ͳ<><CDB3>ְ<EFBFBD><D6B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>^^^^^^^^^^^^^^^^\n");
printf("\t^^^^^^^^^^^^^^^^[6] <20>޸<EFBFBD>ְ<EFBFBD><D6B0><EFBFBD><EFBFBD>Ϣ^^^^^^^^^^^^^^^^\n");
printf("\t^^^^^^^^^^^^^^^^[7] <20>˳<EFBFBD> ϵͳ^^^^^^^^^^^^^^^^\n");
printf("\t################################################\n");
}
int baocun(struct worker *wo)
{
FILE *fp=NULL;
fp=fopen("C:worker.dat","ab+");
fwrite(wo,sizeof(struct worker),1,fp);
fclose(fp);
}
int add() //<2F><><EFBFBD><EFBFBD>ְ<EFBFBD><D6B0><EFBFBD><EFBFBD>Ϣ
{
int num=0,i=0;
struct worker temp;
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD>ְ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
scanf("%d",&num);
for(i=0;i<num;i++)
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>%d<><64>ְ<EFBFBD><D6B0><EFBFBD><EFBFBD>Ϣ\n",i+1);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
scanf("%s",temp.name);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
scanf("%s",temp.id);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
scanf("%d",&temp.salary1);
printf("ְ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
scanf("%d",&temp.salary2);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
scanf("%d",&temp.salary3);
wo[number++]=temp; //д<><EFBFBD><EBB5BD><EFBFBD><EFBFBD>
baocun(&temp); //д<><EFBFBD>ļ<EFBFBD>
}
printf("<EFBFBD><EFBFBD><EFBFBD>ӳɹ<EFBFBD>\n");
}
int see() //<2F>鿴ְ<E9BFB4><D6B0><EFBFBD><EFBFBD>Ϣ
{
int i=0;
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȫ<EFBFBD><EFBFBD>Ա<EFBFBD><EFBFBD>\n");
6 years ago
printf("\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\tְ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
6 years ago
while(i<number)
{
printf("\t%s\t%s\t%d\t%d\t%d\n",wo[i].id,wo[i].name,wo[i].salary1,wo[i].salary2,wo[i].salary3);
i++;
}
}
int search() //<2F><><EFBFBD><EFBFBD>ְ<EFBFBD><D6B0><EFBFBD><EFBFBD>Ϣ
{
int n;
printf("1 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
printf("2 <20><><EFBFBD><EFBFBD><EFBFBD>Ų<EFBFBD><C5B2><EFBFBD>\n");
scanf("%d",&n);
switch(n)
{
case 1:xmcz(); break;
case 2:ghcz(); break;
default: printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n"); break;
}
}
int xmcz() //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
char name[30];
int i=0;
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD>ְ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
scanf("%s",name);
system("cls");
6 years ago
printf("\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\tְ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
6 years ago
for(i=0;i<number;i++)
{
if(strcmp(name,wo[i].name)==0)
printf("\t%s\t%s\t%d\t%d\t%d\n",wo[i].id,wo[i].name,wo[i].salary1,wo[i].salary2,wo[i].salary3);
6 years ago
else
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
6 years ago
}
}
int ghcz() //<2F><><EFBFBD>Ų<EFBFBD><C5B2><EFBFBD>
{
char id[10];
int i=0;
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD>ְ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
scanf("%s",id);
system("cls");
6 years ago
printf("\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\tְ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
6 years ago
for(i=0;i<number;i++)
{
if(strcmp(id,wo[i].id)==0)
printf("\t%s\t%s\t%d\t%d\t%d\n",wo[i].id,wo[i].name,wo[i].salary1,wo[i].salary2,wo[i].salary3);
6 years ago
else
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n") ;
6 years ago
}
}
int del() //ɾ<><C9BE>ְ<EFBFBD><D6B0><EFBFBD><EFBFBD>Ϣ
{
int n;
printf("1 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE>\n");
printf("2 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE>\n");
scanf("%d",&n);
switch(n)
{
case 1:xmsc(); break;
case 2:ghsc(); break;
default: printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n"); break;
}
}
int xmsc() //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE>
{
FILE *fp=NULL;
char name[30];
int i=0,j=0;
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫɾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ְ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
scanf("%s",name);
for(i=0;i<number;i++)
{
if(strcmp(name,wo[i].name)==0)
{
for(j=i;j<number-1;j++)
{wo[j]=wo[j+1];}number--;
6 years ago
}
else
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n") ;
6 years ago
}
fp=fopen("C://woker.dat","wb"); //<2F><>ʣ<EFBFBD><CAA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD>ļ<EFBFBD> <20><>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
for(i=0;i<number;i++)
{
fwrite(&wo[i],sizeof(struct worker),1,fp);
}
fclose(fp);
printf("ɾ<EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD>\n");
}
int ghsc() //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɾ<EFBFBD><C9BE>
{
FILE *fp=NULL;
char id[10];
int i=0,j=0;
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫɾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ְ<EFBFBD><EFBFBD><EFBFBD>Ĺ<EFBFBD><EFBFBD>ţ<EFBFBD>");
scanf("%s",id);
for(i=0;i<number;i++)
{
if(strcmp(id,wo[i].id)==0)
{
for(j=i;j<number-1;j++)
{wo[j]=wo[j+1];}number--;
6 years ago
}
else
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n") ;
6 years ago
}
fp=fopen("C://woker.dat","wb"); //<2F><>ʣ<EFBFBD><CAA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD>ļ<EFBFBD> <20><>ɾ<EFBFBD><C9BE><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
for(i=0;i<number;i++)
{
fwrite(&wo[i],sizeof(struct worker),1,fp);
}
fclose(fp);
printf("ɾ<EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD>\n");
}
int salary() //ͳ<><CDB3>ְ<EFBFBD><D6B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
int i=0;
double s=0.0;
double sum[100];
for(i=0;i<number;i++)
{
sum[i]=wo[i].salary1+wo[i].salary2+wo[i].salary3;
printf("%s<><73><EFBFBD>ܹ<EFBFBD><DCB9><EFBFBD>Ϊ<EFBFBD><CEAA>%f\n",wo[i].name,sum[i]);
}
for(i=0;i<number;i++)
{
s+=sum[i];
}
printf("ƽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>%f\n",s/number);
}
int modify() //<2F>޸<EFBFBD>ְ<EFBFBD><D6B0><EFBFBD><EFBFBD>Ϣ
{
int m=0;
printf("<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD>޸ĵķ<EFBFBD>ʽ:\n");
printf("1 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸<EFBFBD>\n");
printf("2 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸<EFBFBD>\n");
scanf("%d",&m);
switch(m)
{
case 1:xmxg();break;
case 2:ghxg();break;
default:printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!\n");break;
}
}
int xmxg() //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸<EFBFBD>
{
FILE *fp=NULL;
char name[30];
int i=0;
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>޸ĵ<EFBFBD>ְ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
scanf("%s",name);
for(i=0;i<number;i++)
{
if(strcmp(name,wo[i].name));
else
break;
}
6 years ago
printf("\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\tְ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
6 years ago
printf("\t%s\t%s\t%d\t%d\t%d\n",wo[i].id,wo[i].name,wo[i].salary1,wo[i].salary2,wo[i].salary3);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ְԱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ");
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
scanf("%s",wo[i].name);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
scanf("%s",wo[i].id);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
scanf("%d",&wo[i].salary1);
printf("ְ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
scanf("%d",&wo[i].salary2);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
scanf("%d",&wo[i].salary3);
fp=fopen("C://worker.dat","wb");
for(i=0;i<number;i++)
{fwrite(&wo[i],sizeof(struct worker),1,fp);}
fclose(fp);printf("====><3E>޸ijɹ<C4B3><C9B9><EFBFBD>\n");
}
int ghxg() //<2F><><EFBFBD>չ<EFBFBD><D5B9><EFBFBD><EFBFBD>޸<EFBFBD>
{
FILE *fp=NULL;
char id[10];
int i=0;
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>޸ĵ<EFBFBD>ְ<EFBFBD><EFBFBD><EFBFBD>Ĺ<EFBFBD><EFBFBD>ţ<EFBFBD>");
scanf("%s",id);
for(i=0;i<number;i++)
{
if(strcmp(id,wo[i].id));
else
break;
}
6 years ago
printf("\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\tְ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
6 years ago
printf("\t%s\t%s\t%d\t%d\t%d\n",wo[i].id,wo[i].name,wo[i].salary1,wo[i].salary2,wo[i].salary3);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ְԱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ");
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
scanf("%s",wo[i].name);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
scanf("%s",wo[i].id);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
scanf("%d",&wo[i].salary1);
printf("ְ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
scanf("%d",&wo[i].salary2);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
scanf("%d",&wo[i].salary3);
fp=fopen("C://worker.dat","wb");
for(i=0;i<number;i++)
{fwrite(&wo[i],sizeof(struct worker),1,fp);}
fclose(fp);
printf("====><3E>޸ijɹ<C4B3><C9B9><EFBFBD>\n");
}
int back()
{
printf("\t<EFBFBD><EFBFBD>Enter<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD><EFBFBD>\n");
}