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.

327 lines
7.1 KiB

6 years ago
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int i,j,k,y;
FILE *fp;
struct stu {
int num;
char name[30];
double cscore;
};
struct stu s[100];
int fun() { // Ŀ¼<C4BF><C2BC><EFBFBD><EFBFBD>
int n;
system("cls");
printf("\n\n\t\t\t\t<EFBFBD><EFBFBD>ӭʹ<EFBFBD>óɼ<EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><EFBFBD> ");
printf("\n\n\t\t\t");
printf("************ <20><> <20><> *************\n");
printf("\t\t\t[1]<5D><><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD>Ϣ\n");
printf("\t\t\t[2]<5D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD>Ϣ\n");
printf("\t\t\t[3]<5D>޸<EFBFBD>ѧ<EFBFBD><D1A7><EFBFBD>ɼ<EFBFBD>\n");
printf("\t\t\t[4]<5D><>ѯѧ<D1AF><D1A7><EFBFBD><EFBFBD>Ϣ\n");
printf("\t\t\t[5]<5D>ֶ<EFBFBD><D6B6><EFBFBD>ʾѧ<CABE><D1A7><EFBFBD>ɼ<EFBFBD>\n");
printf("\t\t\t[6]<5D><>ѯѧ<D1AF><D1A7>ƽ<EFBFBD><C6BD><EFBFBD>ֺͼ<D6BA><CDBC><EFBFBD><EFBFBD><EFBFBD>\n");
printf("\t\t\t[7]ѧ<><D1A7><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD>\n");
printf("\t\t\t[8]<5D><>ԭ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD>Ϣ\n");
printf("\t\t\t[9]<5D>˳<EFBFBD><CBB3>ɼ<EFBFBD><C9BC><EFBFBD>¼<EFBFBD><C2BC>\n");
printf("\t\t\t");
for(i=0; i<32; i++)
printf("-");
printf("\n\n");
printf("\n\t\t\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD>");
scanf("%d",&n);
return n;
}
void input() {
system("cls");
i=0;
fp=fopen("stuinfo","w");
printf("*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD>š<EFBFBD><C5A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 0*\n");
do {
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD>ţ<EFBFBD>");
scanf("%d",&s[i].num);
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 <20><><EFBFBD>Գɼ<D4B3><C9BC><EFBFBD>");
scanf("%lf",&s[i].cscore);
if(s[i].num!=0)
fprintf(fp,"%d%-4s%.1lf\n",s[i].num,s[i].name,s[i].cscore);
} while(s[i].num!=0);
fclose(fp);
}
void output() {
if((fp=fopen("stuinfo","r"))==NULL) {
printf("<EFBFBD>򲻿<EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>\n");
}
printf("\t\t\t ȫ<><C8AB><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2>\n");
k=0;
while(fscanf(fp,"%d%s%lf",&s[k].num,s[k].name,&s[k].cscore)!=EOF) {
printf("\t\t\t%d\t%s\t%.1lf\n",s[k].num,s[k].name,s[k].cscore);
k++;
}
fclose(fp);
}
void add() {
system("cls");
i=0;
fp=fopen("stuinfo","a");
printf("*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD>š<EFBFBD><C5A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɼ<EFBFBD><C9BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 0*\n");
do {
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD>ţ<EFBFBD>");
scanf("%d",&s[i].num);
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 <20><><EFBFBD>Գɼ<D4B3><C9BC><EFBFBD>");
scanf("%lf",&s[i].cscore);
if(s[i].num!=0)
fprintf(fp,"%d%-4s%.1lf\n",s[i].num,s[i].name,s[i].cscore);
} while(s[i].num!=0);
fclose(fp);
}
void modify() { //<2F>޸<EFBFBD>
char st[30];
int x,num;
double nu;
long h;
k=0;
system("cls");
if((fp=fopen("stuinfo","r"))==NULL) {
printf("<EFBFBD>򲻿<EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>\n");
return;
}
while(fscanf(fp,"%d%s%lf",&s[k].num,s[k].name,&s[k].cscore)!=EOF) {
k++;
}
fclose(fp);
printf("[1]<5D><>ѧ<EFBFBD>Ų<EFBFBD>ѯ\n[2]<5D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ\n<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
scanf("%d",&x);
if(x==1) {
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD>ţ<EFBFBD>");
scanf("%d",&num);
for(i=0; i<k; i++)
if(num==s[i].num) {
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸ĵijɼ<EFBFBD><EFBFBD><EFBFBD>\n");
scanf("%lf",&nu);
s[i].cscore=nu;
fp=fopen("stuinfo","w");
for(i=0; i<k; i++)
fprintf(fp,"%d%-4s%.1lf\n",s[i].num,s[i].name,s[i].cscore);
fclose(fp);
printf(" <20>޸ijɹ<C4B3> \n");
return;
}
printf(" û<><C3BB><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD>\n");
return;
}
if(x==2) {
printf("<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(" <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>޸ĵijɼ<C4B3><C9BC><EFBFBD>\n");
scanf("%lf",&nu);
s[i].cscore=nu;
fp=fopen("stuinfo","w");
for(i=0; i<k; i++)
fprintf(fp,"%d%-4s%.1lf\n",s[i].num,s[i].name,s[i].cscore);
fclose(fp);
printf(" <20>޸ijɹ<C4B3> \n");
return;
}
printf(" û<><C3BB><EFBFBD>ҵ<EFBFBD><D2B5><EFBFBD>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD>\n");
return;
}
}
void lookat() { //<2F><>ѯ
char st[30];
int x,num;
k=0;
system("cls");
if((fp=fopen("stuinfo","r"))==NULL) {
printf("<EFBFBD>򲻿<EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>\n");
return;
}
while(fscanf(fp,"%d%s%lf",&s[k].num,s[k].name,&s[k].cscore)!=EOF) {
k++;
}
printf("[1]<5D><>ѧ<EFBFBD>Ų<EFBFBD>ѯ\n[2]<5D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ\n<EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
scanf("%d",&x);
if(x==1) {
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD>ţ<EFBFBD>");
scanf("%d",&num);
for(i=0; i<k; i++)
if(num==s[i].num) {
printf("%d %s %.1lf\n",s[i].num,s[i].name,s[i].cscore);
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><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
scanf("%s",st);
for(i=0; i<k; i++)
if(strcmp(s[i].name,st)==0) {
printf("%d %s %.1lf\n",s[i].num,s[i].name,s[i].cscore);
return;
}
printf("<EFBFBD>Բ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><EFBFBD>\n");
}
}
void subsection() { //<2F>ֶ<EFBFBD>
system("cls");
k=0;
if((fp=fopen("stuinfo","r"))==NULL) {
printf("<EFBFBD>򲻿<EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>\n");
}
while(fscanf(fp,"%d%s%lf",&s[k].num,s[k].name,&s[k].cscore)!=EOF) {
k++;
}
printf("\t\t90 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ\n");
for(i=0; i<k; i++)
if(s[i].cscore>=90)
printf("\t\t\t%d %s %.1lf\n",s[i].num,s[i].name,s[i].cscore);
printf("\n\n");
printf("\t\t80 <20><> 89 <20><>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ\n");
for(i=0; i<k; i++)
if(s[i].cscore<90&&s[i].cscore>=80)
printf("\t\t\t%d %s %.1lf\n",s[i].num,s[i].name,s[i].cscore);
printf("\n\n");
printf("\t\t60 <20><> 79 <20><>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ\n");
for(i=0; i<k; i++)
if(s[i].cscore>=60&&s[i].cscore<80)
printf("\t\t\t%d %s %.1lf\n",s[i].num,s[i].name,s[i].cscore);
printf("\n\n");
printf("\t\t60 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧ<EFBFBD><D1A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ\n");
for(i=0; i<k; i++)
if(s[i].cscore<60)
printf("\t\t\t%d %s %.1lf\n",s[i].num,s[i].name,s[i].cscore);
printf("\n\n");
}
void average() { //ƽ<><C6BD><EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
system("cls");
k=0;
double sum=0,average,jgl;
int a=0;
if((fp=fopen("stuinfo","r"))==NULL) {
printf("<EFBFBD>򲻿<EFBFBD><EFBFBD>ļ<EFBFBD><EFBFBD><EFBFBD>\n");
}
while(fscanf(fp,"%d%s%lf",&s[k].num,s[k].name,&s[k].cscore)!=EOF) {
k++;
}
for(i=0; i<k; i++){
sum+=s[i].cscore;
}
average=sum/k;
printf("ƽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>%.1lf\n",average);
for(i=0; i<k; i++)
if(s[i].cscore>=60){
a++;
}
jgl=((double)a/(double)k)*100;
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>%.1lf%%\n",jgl);
}
void rank() { //<2F><><EFBFBD><EFBFBD>
struct stu t;
k=0;
system("cls");
if((fp=fopen("stuinfo","r"))==NULL) {
printf("<EFBFBD>򲻿<EFBFBD><EFBFBD>ļ<EFBFBD>!\n");
}
while(fscanf(fp,"%d%s%lf",&s[k].num,s[k].name,&s[k].cscore)!=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 <09><> %d <20><> %d %-4s %.1lf\n",i+1,s[i].num,s[i].name,s[i].cscore);
}
void choose(int n) { //Ŀ¼
system("cls");
switch(n) {
case 1:
input();
printf("\n\n\n\n\t\t\t <09>Ƿ񷵻أ<F1B7B5BB>\n\t\t <20><><EFBFBD><EFBFBD> 1 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 2 <20>˳<EFBFBD><CBB3><EFBFBD><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 <09>Ƿ񷵻أ<F1B7B5BB>\n\t\t <20><><EFBFBD><EFBFBD> 1 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 2 <20>˳<EFBFBD><CBB3><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 <09>Ƿ񷵻أ<F1B7B5BB>\n\t\t <20><><EFBFBD><EFBFBD> 1 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 2 <20>˳<EFBFBD><CBB3><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 <09>Ƿ񷵻أ<F1B7B5BB>\n\t\t <20><><EFBFBD><EFBFBD> 1 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 2 <20>˳<EFBFBD><CBB3><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 <09>Ƿ񷵻أ<F1B7B5BB>\n\t\t <20><><EFBFBD><EFBFBD> 1 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 2 <20>˳<EFBFBD><CBB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
scanf("%d",&y);
if(y==1)
choose(fun());
break;
case 6:
average();
printf("\n\n\n\n\t\t\t <09>Ƿ񷵻أ<F1B7B5BB>\n\t\t <20><><EFBFBD><EFBFBD> 1 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 2 <20>˳<EFBFBD><CBB3><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 <09>Ƿ񷵻أ<F1B7B5BB>\n\t\t <20><><EFBFBD><EFBFBD> 1 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 2 <20>˳<EFBFBD><CBB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
scanf("%d",&y);
if(y==1)
choose(fun());
break;
case 8:
add();
printf("\n\n\n\n\t\t\t <09>Ƿ񷵻أ<F1B7B5BB>\n\t\t <20><><EFBFBD><EFBFBD> 1 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 2 <20>˳<EFBFBD><CBB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
scanf("%d",&y);
if(y==1)
choose(fun());
break;
case 9:
exit(0);
break;
default:
printf("\n\n\t\t\t <09><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><EFBFBD><EEB2BB><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
choose(fun());
}
}
int main() { // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int n;
system("cls");
n=fun();
choose(n);
}