|
|
|
|
#include "stdio.h"
|
|
|
|
|
#include "stdlib.h"
|
|
|
|
|
#define FILENAME "worker.bin"
|
|
|
|
|
#define N 20
|
|
|
|
|
/*******************************************************
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
*******************************************************/
|
|
|
|
|
struct worker
|
|
|
|
|
{
|
|
|
|
|
int number; /*<2A><><EFBFBD><EFBFBD>*/
|
|
|
|
|
int counts; /*<2A><><EFBFBD><EFBFBD>*/
|
|
|
|
|
int grade; /*<2A><><EFBFBD><EFBFBD>*/
|
|
|
|
|
};
|
|
|
|
|
/*******************************************************
|
|
|
|
|
<EFBFBD><EFBFBD>ʾ<EFBFBD>˵<EFBFBD>
|
|
|
|
|
*******************************************************/
|
|
|
|
|
void xinxi()
|
|
|
|
|
{
|
|
|
|
|
printf("\n+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
|
|
|
|
|
printf("+ ְ<><D6B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͳ<EFBFBD><CDB3>ϵͳ +\n");
|
|
|
|
|
printf("+ +\n");
|
|
|
|
|
printf("+ 1. ְ<><D6B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD> +\n");
|
|
|
|
|
printf("+ +\n");
|
|
|
|
|
printf("+ 2. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> +\n");
|
|
|
|
|
printf("+ +\n");
|
|
|
|
|
printf("+ 3. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> +\n");
|
|
|
|
|
printf("+ +\n");
|
|
|
|
|
printf("+ 4. <20><>ְ<EFBFBD><D6B0><EFBFBD><EFBFBD><EFBFBD>Ž<EFBFBD><C5BD><EFBFBD><EFBFBD><EFBFBD>Ϣɾ<CFA2><C9BE> +\n");
|
|
|
|
|
printf("+ +\n");
|
|
|
|
|
printf("+ 5. <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> +\n");
|
|
|
|
|
printf("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
|
|
|
|
|
}
|
|
|
|
|
/*******************************************************
|
|
|
|
|
<EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļ
|
|
|
|
|
*******************************************************/
|
|
|
|
|
readFromFile(struct worker w[])
|
|
|
|
|
{
|
|
|
|
|
FILE *fp=NULL;
|
|
|
|
|
int i=0;
|
|
|
|
|
fp=fopen(FILENAME,"rb"); /*<2A><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>*/
|
|
|
|
|
if(fp!=NULL)
|
|
|
|
|
{
|
|
|
|
|
while(!feof(fp)) /*<2A><><EFBFBD>ļ<EFBFBD><C4BC>ж<EFBFBD><D0B6><EFBFBD>ѧ<EFBFBD><D1A7>*/{
|
|
|
|
|
if(i>=N)
|
|
|
|
|
break;
|
|
|
|
|
if(fread(w+i,sizeof(w),1,fp)==1)
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
fclose(fp);
|
|
|
|
|
}
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
/*******************************************************
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ְ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|
|
|
|
*******************************************************/
|
|
|
|
|
int f(struct worker w[],int length)
|
|
|
|
|
{
|
|
|
|
|
int i=length;
|
|
|
|
|
while(i<N){
|
|
|
|
|
printf("<EFBFBD><EFBFBD>%d<><64>ְ<EFBFBD><D6B0>\n",i);
|
|
|
|
|
printf("\n");
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>빤<EFBFBD><EFBFBD>(<28><>ְ<EFBFBD><D6B0><EFBFBD><EFBFBD>Ϊ0<CEAA><30><EFBFBD><EFBFBD>):\n");/*<2A><><EFBFBD>빤<EFBFBD><EBB9A4>*/
|
|
|
|
|
scanf("%d",&w[i].number);
|
|
|
|
|
if(w[i].number==0)
|
|
|
|
|
break;
|
|
|
|
|
printf("\n");
|
|
|
|
|
printf("\n");
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:\n");/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
|
|
|
|
|
scanf("%d",&w[i].counts);
|
|
|
|
|
printf("\n");
|
|
|
|
|
i++;
|
|
|
|
|
}
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
/*******************************************************
|
|
|
|
|
<EFBFBD><EFBFBD><EFBFBD><EFBFBD>:<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>벢<EFBFBD>ۼ<EFBFBD>
|
|
|
|
|
*******************************************************/
|
|
|
|
|
void input(struct worker w[],int length)
|
|
|
|
|
{
|
|
|
|
|
int i=1;
|
|
|
|
|
int number,counts;
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>빤<EFBFBD><EFBFBD>:");
|
|
|
|
|
scanf("%d",&number);
|
|
|
|
|
while(number!=0)
|
|
|
|
|
{
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:\n");
|
|
|
|
|
scanf("%d",&counts);
|
|
|
|
|
for(i=0;i<length;i++)
|
|
|
|
|
if(w[i].number==number)
|
|
|
|
|
{
|
|
|
|
|
w[i].counts+=counts;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if(i>=length)
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD>Ų<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:\n");
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>빤<EFBFBD><EFBFBD>:");
|
|
|
|
|
scanf("%d",&number);printf("<EFBFBD><EFBFBD><EFBFBD>Ų<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:\n");
|
|
|
|
|
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>빤<EFBFBD><EFBFBD>:");
|
|
|
|
|
scanf("%d",&number);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
int main (){
|
|
|
|
|
|
|
|
|
|
int choice;
|
|
|
|
|
struct worker w[N];
|
|
|
|
|
int NUM;
|
|
|
|
|
char stuName[100];
|
|
|
|
|
int stuNum;
|
|
|
|
|
int length=0;
|
|
|
|
|
length=readFromFile(w);//<2F><><EFBFBD><EFBFBD>
|
|
|
|
|
do
|
|
|
|
|
{ xinxi();
|
|
|
|
|
scanf("%d",&choice);
|
|
|
|
|
switch(choice)
|
|
|
|
|
{ case 1:
|
|
|
|
|
length=f(w,length);
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
input(w,length);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}while(1);
|
|
|
|
|
}
|