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.

301 lines
6.7 KiB

6 years ago
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int i,j,k,y;
FILE *fp;
struct stu
{
int no;
char name[30];
float cscore;
long a;
};struct stu s[100];
int fun()
{
int n,i;
system("cls");
printf("\n\n\t\t\t\t <20>ɼ<EFBFBD><C9BC><EFBFBD>¼<EFBFBD><C2BC>");
printf("\n\n\t\t\t");
for(i=0;i<33;i++)
printf("*");
printf("\n");
printf("\t\t\t *********<2A>˵<EFBFBD>********\n");
printf("\t\t\t* 1<><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2> \t*\n");
printf("\t\t\t* 2<><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2> \t*\n");
printf("\t\t\t* 3<><33><EFBFBD>޸ijɼ<C4B3><C9BC><EFBFBD> \t*\n");
printf("\t\t\t* 4<><34><EFBFBD><EFBFBD>ѯ<EFBFBD><D1AF> \t*\n");
printf("\t\t\t* 5<><35><EFBFBD><EFBFBD>ʾ<EFBFBD>ɼ<EFBFBD><C9BC>ֶε<D6B6>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2> \t*\n");
printf("\t\t\t* 6<><36><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD><EFBFBD>ʡ<EFBFBD>ƽ<EFBFBD><C6BD><EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD>߷ֺ<DFB7><D6BA><EFBFBD><EFBFBD>ͷ֣<CDB7> \t*\n");
printf("\t\t\t* 7<><37>ѧ<EFBFBD><D1A7><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> \t*\n");
printf("\t\t\t* 8<><38><EFBFBD>˳<EFBFBD><CBB3>ɼ<EFBFBD><C9BC><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD> \t*\n");
printf("\t\t\t");
for(i=0;i<33;i++)
printf("*");
printf("\n\n");
printf("\n\t\t\t <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD>");
scanf("%d",&n);
return n;
}
void input()
{
system("cls");
i=0;
fp=fopen("out.dat","w");
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>0<EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD>Ľ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
do
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD>ţ<EFBFBD>");
scanf("%d",&s[i].no);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
scanf("%s",s[i].name);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>C<EFBFBD><EFBFBD><EFBFBD>Գɼ<EFBFBD><EFBFBD><EFBFBD>");
scanf("%f",&s[i].cscore);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӳɼ<EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>");
scanf("%ld",&s[i].a);
if(s[i].no!=0)
fprintf(fp,"%d %-4s %.1f %ld\n",s[i].no,s[i].name,s[i].cscore,s[i].a);
}while(s[i].no!=0);
fclose(fp);
}
void output()
{
if((fp=fopen("out.dat","r"))==NULL)
{
printf("Cannot open the file!\n");
}
printf("\t\t\tȫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD>\n");
k=0;
while(fscanf(fp,"%d%s%f%ld",&s[k].no,s[k].name,&s[k].cscore,&s[k].a)!=EOF)
{
printf("\t\t\t%d\t%s\t%.lf\t%ld\n",s[k].no,s[k].name,s[k].cscore,s[k].a);
k++;
}
fclose(fp);
}
void modify()
{
char st[30];
int x,num;
float nu;
long h;
k=0;
system("cls");
if((fp=fopen("out.dat","r"))==NULL)
{
printf("Cannot open the file!\n");
return;
}
while(fscanf(fp,"%d%s%f%ld",&s[k].no,s[k].name,&s[k].cscore,&s[k].a)!=EOF)
{
k++;
}
fclose(fp);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD>޸ģ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸ģ<EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
scanf("%d",&x);
if(x==1)
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸ijɼ<EFBFBD><EFBFBD>˵<EFBFBD>ѧ<EFBFBD>ţ<EFBFBD>");scanf("%d",&num);
for(i=0;i<k;i++)
if(num==s[i].no)
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸ĵijɼ<EFBFBD><EFBFBD><EFBFBD>\n");
scanf("%f",&nu);
s[i].cscore=nu;
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸ĵ<EFBFBD>ʱ<EFBFBD>\n");
scanf("%ld",&h);
s[i].a=h;
fp=fopen("out.dat","w");
for(i=0;i<k;i++)
fprintf(fp,"%d %s %.lf %ld\n",s[i].no,s[i].name,s[i].cscore,s[i].a);
fclose(fp);
printf("<EFBFBD>޸ijɹ<EFBFBD>\n");
return;
}
printf("û<EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD>\n");
return;
}
if(x==2)
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸ijɼ<EFBFBD><EFBFBD>˵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
scanf("%s",st);
for(i=0;i<k;i++)
if(strcmp(s[i].name,st)==0)
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸ijɼ<EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>\n");
scanf("%ld",&h);
s[i].a=h;
fp=fopen("out.dat","w");
for(i=0;i<k;i++)
fprintf(fp,"%d %s %.lf %ld\n",s[i].no,s[i].name,s[i].cscore,s[i].a);
fclose(fp);
printf("<EFBFBD>޸ijɹ<EFBFBD>\n");
return;
}
printf("û<EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD>\n");
return;
}
}
void lookat()
{
char st[30];
int x,num;
k=0;
system("cls");
if((fp=fopen("out.dat","r"))==NULL)
{
printf("Cannot open the file!\n");
return;
}
while(fscanf(fp,"%d%s%f%ld",&s[k].no,s[k].name,&s[k].cscore,&s[k].a)!=EOF)
{
k++;
}
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD>ѧ<EFBFBD>Ų<EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
scanf("%d",&x);
if(x==1)
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD>ѧ<EFBFBD>ţ<EFBFBD>");
scanf("%d",&num);
for(i=0;i<k;i++)
if(num==s[i].no)
{
printf("%d %s %.1f%ld\n",s[i].no,s[i].name,s[i].cscore,s[i].a);
return;
}
printf("<EFBFBD>Բ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
return;
}
if(x==2)
{
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
scanf("%s",st);
for(i=0;i<k;i++)
if(strcmp(s[i].name,st)==0)
{
printf("%d % s %.1f %ld\n",s[i].no,s[i].name,s[i].cscore,s[i].a);
return;
}
printf("<EFBFBD>Բ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҳ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
}
}
void subsection()
{
system("cls");
k=0;
if((fp=fopen("out.dat","r"))==NULL)
{
printf("Cannot open the file!\n");
}
while(fscanf(fp,"%d%s%f%ld",&s[k].no,s[k].name,&s[k].cscore,&s[k].a)!=EOF)
{
k++;
}
printf("\t\t\t 90<39><30><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>\n");
for(i=0;i<k;i++)
if(s[i].cscore>=90)
printf("\t\t\t%d %s %.1f %ld\n",s[i].no,s[i].name,s[i].cscore,s[i].a);
printf("\n\n");
printf("\t\t\t 80<38><30>89<38><39>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>\n");
for(i=0;i<k;i++)
if(s[i].cscore<90&&s[i].cscore>=80)
printf("\t\t\t%d %s %.1f %ld\n",s[i].no,s[i].name,s[i].cscore,s[i].a);
printf("\n\n");
printf("\t\t\t 60<36><30>79<37><39>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>\n");
for(i=0;i<k;i++)
if(s[i].cscore>=60&&s[i].cscore<80)
printf("\t\t\t%d %s %.1f %ld\n",s[i].no,s[i].name,s[i].cscore,s[i].a);
printf("\n\n");
}
void demonstrate()
{
int max,min,score;
double avg=0;
scanf("%d",&score);
max=min=score;
avg+=score;
for(i=0; i<29; i++)
{
scanf("%d",&score);
if(score>max) max=score;
if(score<min) min=score;
avg+=score;
}
avg=avg/30;
printf("<EFBFBD><EFBFBD><EFBFBD>߷<EFBFBD>max=%d,<2C><><EFBFBD>ͷ<EFBFBD>min=%d,ƽ<><C6BD><EFBFBD><EFBFBD>avg=%lf\n",max,min,avg);
}
void rank()
{
struct stu t;
k=0;
system("cls");
if((fp=fopen("out.dat","r"))==NULL)
{
printf("Cannot open the file!\n");
}
while(fscanf(fp,"%d%s%f%ld",&s[k].no,s[k].name,&s[k].cscore,&s[k].a)!=EOF)
{
k++;
}
for(i=0;i<k;i++)
for(j=i+1;j<k+1;j++)
if(s[i].cscore<s[j].cscore)
{t=s[i];s[i]=s[j];s[j]=t;}
for(i=0;i<k;i++)
printf("\t\t\t <20><>%d<><64>%d %-4s %.1f %ld\n",i+1,s[i].no,s[i].name,s[i].cscore,s[i].a);
}
void choose(int n)
{
system("cls");
switch(n)
{
case 1:input();
printf("\n\n\n\n\t\t\t<EFBFBD>Ƿ񷵻أ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD>أ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2<EFBFBD><EFBFBD>ʾ<EFBFBD>˳<EFBFBD>!\n");
scanf("%d",&y);
if(y==1)
choose(fun());break;
case 2:output();
printf("\n\n\n\n\t\t\t<EFBFBD>Ƿ񷵻أ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD>أ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2<EFBFBD><EFBFBD>ʾ<EFBFBD>˳<EFBFBD><EFBFBD><EFBFBD>\n");
scanf("%d",&y);
if(y==1)
choose(fun());break;
case 3:modify();
printf("\n\n\n\n\t\t\t<EFBFBD>Ƿ񷵻أ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD>أ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2<EFBFBD><EFBFBD>ʾ<EFBFBD>˳<EFBFBD><EFBFBD><EFBFBD>\n");
scanf("%d",&y);
if(y==1)
choose(fun());break;
case 4:lookat();
printf("\n\n\n\n\t\t\t<EFBFBD>Ƿ񷵻أ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD>أ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2<EFBFBD><EFBFBD>ʾ<EFBFBD>˳<EFBFBD><EFBFBD><EFBFBD>\n");
scanf("%d",&y);
if(y==1)
choose(fun());break;
case 5:subsection();
printf("\n\n\n\n\t\t\t<EFBFBD>Ƿ񷵻أ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD>أ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2<EFBFBD><EFBFBD>ʾ<EFBFBD>˳<EFBFBD><EFBFBD><EFBFBD>\n");
scanf("%d",&y);
if(y==1)
choose(fun());break;
case 6:demonstrate();
printf("\n\n\n\n\t\t\t<EFBFBD>Ƿ<EFBFBD><EFBFBD>ϻأ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD>أ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2<EFBFBD><EFBFBD>ʾ<EFBFBD>˳<EFBFBD><EFBFBD><EFBFBD>\n");
scanf("%d",&y);
if(y==1)
choose(fun());break;
case 7:rank();
printf("\n\n\n\n\t\t\t<EFBFBD>Ƿ<EFBFBD><EFBFBD>ϻأ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><EFBFBD>ʾ<EFBFBD><EFBFBD><EFBFBD>أ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2<EFBFBD><EFBFBD>ʾ<EFBFBD>˳<EFBFBD><EFBFBD><EFBFBD>\n");
scanf("%d",&y);
if(y==1)
choose(fun());break;
case 8:exit(0);break;
default:printf("\n\n\t\t\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD>е<EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
choose(fun());
}
}
int main(void)
{
int n;
system("cls");
n=fun();
choose(n);
}