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.

442 lines
8.8 KiB

6 years ago
#include"stdio.h"
#include"stdlib.h"
#include"string.h"
#include"math.h"
struct student
{
char xh[12];
char name[20];
char sex[20];
int yw;
int sx;
int yy;
int zf;
};
void menu()
{
printf("\n\n\n");
printf("\t\t|----------------ѧ<><D1A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵͳ---------------|\n");
printf("\t\t|\t 0 <20>˳<EFBFBD> |\n");
printf("\t\t|\t 1 ѧ<><D1A7><EFBFBD><EFBFBD>Ϣ¼<CFA2><C2BC> |\n");
printf("\t\t|\t 2 ѧ<><D1A7><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD>ѯ |\n");
printf("\t\t|\t 3 <20><>ʾȫ<CABE><C8AB>ѧ<EFBFBD><D1A7><EFBFBD>ɼ<EFBFBD> |\n");
printf("\t\t|\t 4 <20><EFBFBD><E9BFB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>γɼ<CEB3><C9BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> |\n");
printf("\t\t|\t 5 ѧ<><D1A7><EFBFBD><EFBFBD><EFBFBD>Ƴɼ<C6B3><C9BC><EFBFBD><EFBFBD><EFBFBD> |\n");
printf("\t\t|\t 6 ɾ<><C9BE>ָ<EFBFBD><D6B8>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD>Ϣ |\n");
printf("\t\t|\t 7 <20>޸<EFBFBD>ָ<EFBFBD><D6B8>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD>Ϣ |\n");
printf("\t\t|-------------------------------------------|\n");
printf("\n");
}
void chenjifenxi();
void add();
void search();
void printall();
void score_section();
void del();
void modify();
int main()
{
menu();
int n;
printf(" <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0-7: ");
scanf("%d",&n);
while(n)
{
switch(n)
{
case 0:break;
case 1:add();break;
case 2:search();break;
case 3:printall();break;
case 4:score_section();break;
case 5:chenjifenxi();break;
case 6:del();break;
case 7:modify();break;
default:printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
}
menu();
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD>밴0-7,<2C><><EFBFBD>߰<EFBFBD>0<EFBFBD>˳<EFBFBD>");
scanf("%d",&n);
}
return 0;
}
void add()
{
struct student boy[20];
FILE *fp;
int a=1;
int i=0,flag=0;
fp=fopen("student.txt","a+");
if(fp==NULL)
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>");
}
while(a==1)
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD>");
scanf("%s",boy[i].xh);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
scanf("%s",boy[i].name);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD>");
scanf("%s",boy[i].sex);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
scanf("%d",&boy[i].yw);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ");
scanf("%d",&boy[i].sx);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӣ<EFBFBD><EFBFBD>");
scanf("%d",&boy[i].yy);
boy[i].zf=boy[i].yw+boy[i].yy+boy[i].sx;
fprintf(fp,"%s %s %s %d %d %d %d",boy[i].xh,boy[i].name,boy[i].sex,boy[i].yw,boy[i].sx,boy[i].yy,boy[i].zf);
fprintf(fp,"\n");
i++;
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> :");
scanf("%d",&a);
if(a==0)
{
break;
}
}
fclose(fp);
}
void search()
{
FILE *fp;
char ch[20];
int i=0,flag=0;
struct student boy[50];
fp=fopen("student.txt","ab+");
if(fp==NULL)
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>");
}
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",&ch);
while(!feof(fp))
{
fscanf(fp,"%s%s%s%d%d%d%d",boy[i].xh,boy[i].name,boy[i].sex,&boy[i].yw,&boy[i].sx,&boy[i].yy,&boy[i].zf);
i++;
}
for(int j=0;j<50;j++)
{
if((strcmp(ch,boy[j].xh)==0)||(strcmp(ch,boy[j].name)==0))
{
printf("ѧ<EFBFBD><EFBFBD>: %s \n<EFBFBD><EFBFBD><EFBFBD><EFBFBD>: %s \n<EFBFBD>Ա<EFBFBD>: %s \n<EFBFBD><EFBFBD><EFBFBD><EFBFBD>: %d \n<EFBFBD><EFBFBD>ѧ: %d \nӢ<EFBFBD><EFBFBD>: %d \n<EFBFBD>ܷ<EFBFBD>: %d",boy[j].xh,boy[j].name,boy[j].sex,boy[j].yw,boy[j].sx,boy[j].yy,boy[j].zf);
flag=1;
}
}
if(flag==0)
{
printf("<EFBFBD><EFBFBD><EFBFBD>޴<EFBFBD><EFBFBD><EFBFBD>");
}
fclose(fp);
}
void printall()
{
FILE *fp;
int i=0,k=0,j,a,b,flag;
struct student boy[50];
struct student gilr;
fp=fopen("student.txt","r");
if(fp==NULL)
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>");
}
while(!feof(fp))
{
fscanf(fp,"%s%s%s%d%d%d%d",boy[i].xh,boy[i].name,boy[i].sex,&boy[i].yw,&boy[i].sx,&boy[i].yy,&boy[i].zf);
i++;
k++;
}
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>밴1\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ijɼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>밴2\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>밴3\n<EFBFBD><EFBFBD><EFBFBD>Ӣ<EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>밴4\n");
scanf("%d",&flag);
if(flag==1)
{
for(a=0;a<k-1;a++)
{
for(b=a+1;b<k-1;b++)
{
if(boy[a].zf<boy[b].zf)
{
gilr=boy[a];
boy[a]=boy[b];
boy[b]=gilr;
}
}
}
}else if(flag==2){
for(a=0;a<k-1;a++)
{
for(b=a+1;b<k-1;b++)
{
if(boy[a].yw<boy[b].yw)
{
gilr=boy[a];
boy[a]=boy[b];
boy[b]=gilr;
}
}
}
}else if(flag==3){
for(a=0;a<k-1;a++)
{
for(b=a+1;b<k-1;b++)
{
if(boy[a].sx<boy[b].sx)
{
gilr=boy[a];
boy[a]=boy[b];
boy[b]=gilr;
}
}
}
}else if(flag==4){
for(a=0;a<k-1;a++)
{
for(b=a+1;b<k-1;b++)
{
if(boy[a].yy<boy[b].yy)
{
gilr=boy[a];
boy[a]=boy[b];
boy[b]=gilr;
}
}
}
}else{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><>򽫴<EFBFBD><F2BDABB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
}
for(j=0;j<k-1;j++)
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>: %s <20><><EFBFBD><EFBFBD>: %d <20><>ѧ: %d Ӣ<><D3A2>: %d <20>ܷ<EFBFBD>: %d",boy[j].name,boy[j].yw,boy[j].sx,boy[j].yy,boy[j].zf);
printf("\n");
}
fclose(fp);
}
void score_section()
{
FILE *fp;
struct student boy[50];
int i=0,k=0;
int a=0,b=0,c=0,d=0,e=0,f=0;
fp=fopen("student.txt","r");
if(fp==NULL)
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>");
}
while(!feof(fp))
{
fscanf(fp,"%s%s%s%d%d%d%d",boy[i].xh,boy[i].name,boy[i].sex,&boy[i].yw,&boy[i].sx,&boy[i].yy,&boy[i].zf);
i++;
k++;
}
for(int j=0;j<k-1;j++)
{
if(boy[j].yw<60)
{
a++;
}
if(boy[j].yw>=60){
b++;
}
if(boy[j].sx<60){
c++;
}
if(boy[j].sx>=60){
d++;
}
if(boy[j].yy<60){
e++;
}if(boy[j].yy>=60){
f++;
}
}
printf("<EFBFBD><EFBFBD><EFBFBD>ĵ<EFBFBD><EFBFBD><EFBFBD>60<EFBFBD><EFBFBD><EFBFBD><EFBFBD>%d<><64>\n<EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD>60<EFBFBD><EFBFBD><EFBFBD><EFBFBD>%d<><64>\n<EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>60<EFBFBD><EFBFBD><EFBFBD><EFBFBD>%d<><64>\n<EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>60<EFBFBD><EFBFBD><EFBFBD><EFBFBD>%d<><64>\nӢ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>60<EFBFBD><EFBFBD><EFBFBD><EFBFBD>%d<><64>\nӢ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>60<EFBFBD><EFBFBD><EFBFBD><EFBFBD>%d<><64>\n",a,b,c,d,e,f);
fclose(fp);
}
void chenjifenxi()
{
FILE *fp;
struct student boy[50];
int i=0,k=0,ywmax,ywmin,sxmax,sxmin,yymax,yymin,ywavg,sxavg,yyavg;
double ywsum=0,sxsum=0,yysum=0,ywpass=0,sxpass=0,yypass=0;
fp=fopen("student.txt","r");
if(fp==NULL)
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>");
}
while(!feof(fp))
{
fscanf(fp,"%s%s%s%d%d%d%d",boy[i].xh,boy[i].name,boy[i].sex,&boy[i].yw,&boy[i].sx,&boy[i].yy,&boy[i].zf);
i++;
k++;
}
ywmax=boy[0].yw;
ywmin=boy[1].yw;
sxmax=boy[0].sx;
sxmin=boy[1].sx;
yymax=boy[0].yy;
yymin=boy[1].yy;
for(int j=0;j<k-1;j++)
{
if(boy[j].yw>ywmax)
{
ywmax=boy[j].yw;
}
if(boy[j].yw<ywmin)
{
ywmin=boy[j].yw;
}
if(boy[j].sx>sxmax)
{
sxmax=boy[j].sx;
}
if(boy[j].sx<sxmin)
{
sxmin=boy[j].sx;
}
if(boy[j].yy>yymax)
{
yymax=boy[j].yy;
}
if(boy[j].yy<yymin)
{
yymin=boy[j].yy;
}
}
for(int m=0;m<k-1;m++)
{
ywsum+=boy[m].yw;
sxsum+=boy[m].sx;
yysum+=boy[m].yy;
}
for(int a=0;a<k-1;a++)
{
if(boy[a].yw>=60)
{
ywpass++;
}
if(boy[a].sx>=60)
{
sxpass++;
}
if(boy[a].yy>=60)
{
yypass++;
}
}
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߷<EFBFBD>:%d <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD>:%d <20><><EFBFBD><EFBFBD>ƽ<EFBFBD><C6BD><EFBFBD><EFBFBD>:%.2f\n<EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD>߷<EFBFBD>:%d <20><>ѧ<EFBFBD><D1A7><EFBFBD>ͷ<EFBFBD>:%d <20><>ѧƽ<D1A7><C6BD><EFBFBD><EFBFBD>:%.2f\nӢ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߷<EFBFBD>:%d Ӣ<><D3A2><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD>:%ld Ӣ<><D3A2>ƽ<EFBFBD><C6BD><EFBFBD><EFBFBD>:%.2f\n",ywmax,ywmin,ywsum/(k-1),sxmax,sxmin,sxsum/(k-1),yymax,yymin,yysum/(k-1));
printf("<EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> %.2f%% \n<EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> %.2f%% \nӢ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> %.2f%%\n",(ywpass/(k-1))*100,(sxpass/(k-1))*100,(yypass/(k-1))*100);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܷ<EFBFBD>:%.0f <20><>ѧ<EFBFBD>ܷ<EFBFBD>:%.0f Ӣ<><D3A2><EFBFBD>ܷ<EFBFBD>:%.0f",ywsum,sxsum,yysum);
fclose(fp);
}
void del()
{
FILE *fp;
int i=0,k=0,z,x,j,flag=0;
char s[12];
struct student boy[50];
fp=fopen("student.txt","r");
if(fp==NULL)
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>");
}
while(!feof(fp))
{
fscanf(fp,"%s%s%s%d%d%d%d",boy[i].xh,boy[i].name,boy[i].sex,&boy[i].yw,&boy[i].sx,&boy[i].yy,&boy[i].zf);
i++;
k++;
}
fclose(fp);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫɾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD>");
scanf("%s",s);
for(j=0;j<k;j++)
{
if(strcmp(s,boy[j].xh)==0)
{
z=j;
flag=1;
}
}
if(flag==1)
{
for(x=z;x<k-1;x++)
{
boy[x]=boy[x+1];
}
k=k-1;//<2F><><EFBFBD>ܸ<EFBFBD><DCB8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>
fp=fopen("student.txt","w");
if(fp==NULL)
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>");
}
for(j=0;j<k-1;j++)
{
fprintf(fp,"%s %s %s %d %d %d %d",boy[j].xh,boy[j].name,boy[j].sex,boy[j].yw,boy[j].sx,boy[j].yy,boy[j].zf);
fprintf(fp,"\n");
}
fclose(fp);
}else{
printf("û<EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD>Ҫɾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ");
}
}
void modify()
{
FILE *fp;
int i=0,k=0,j,z,flag=0;
char s[12];
struct student boy[50];
fp=fopen("student.txt","r");
if(fp==NULL)
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>");
}
while(!feof(fp))
{
fscanf(fp,"%s%s%s%d%d%d%d",boy[i].xh,boy[i].name,boy[i].sex,&boy[i].yw,&boy[i].sx,&boy[i].yy,&boy[i].zf);
i++;
k++;
}
fclose(fp);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>޸<EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD>: ");
scanf("%s",s);
for(j=0;j<k-1;j++)
{
if(strcmp(s,boy[j].xh)==0)
{
z=j;
flag=1;
}
}
if(flag==1)
{
fp=fopen("student.txt","w");
if(fp==NULL)
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>");
}
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD>");
scanf("%s",boy[z].xh);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
scanf("%s",boy[z].name);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ա<EFBFBD>");
scanf("%s",boy[z].sex);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ijɼ<EFBFBD>");
scanf("%d",&boy[z].yw);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD>ɼ<EFBFBD>");
scanf("%d",&boy[z].sx);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӣ<EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD>");
scanf("%d",&boy[z].yy);
boy[z].zf=boy[z].sx+boy[z].yw+boy[z].yy;
for(j=0;j<k-1;j++)
{
fprintf(fp,"%s %s %s %d %d %d %d",boy[j].xh,boy[j].name,boy[j].sex,boy[j].yw,boy[j].sx,boy[j].yy,boy[j].zf);
fprintf(fp,"\n");
}
fclose(fp);
}else{
printf("<EFBFBD><EFBFBD>ҲĪ<EFBFBD>ð취<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҳ<EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD>޸ĵ<EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ");
}
}