diff --git a/e.c b/e.c new file mode 100644 index 0000000..f0879f4 --- /dev/null +++ b/e.c @@ -0,0 +1,301 @@ +#include +#include +#include +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 成绩记录簿"); + printf("\n\n\t\t\t"); + for(i=0;i<33;i++) + printf("*"); + printf("\n"); + printf("\t\t\t *********菜单********\n"); + printf("\t\t\t* 1、创建学生的信息! \t*\n"); + printf("\t\t\t* 2、输出所有学生的信息! \t*\n"); + printf("\t\t\t* 3、修改成绩! \t*\n"); + printf("\t\t\t* 4、查询! \t*\n"); + printf("\t\t\t* 5、显示成绩分段的学生信息! \t*\n"); + printf("\t\t\t* 6、显示及格率、平均分、最高分和最低分! \t*\n"); + printf("\t\t\t* 7、学生成绩排名! \t*\n"); + printf("\t\t\t* 8、退出成绩记录簿! \t*\n"); + printf("\t\t\t"); + for(i=0;i<33;i++) + printf("*"); + printf("\n\n"); + printf("\n\t\t\t 请输入选项:"); + scanf("%d",&n); + return n; +} +void input() +{ + system("cls"); + i=0; + fp=fopen("out.dat","w"); + printf("请以0作为输入学生学号信息的结束!\n"); + do + { + printf("输入学生的学号:"); + scanf("%d",&s[i].no); + printf("输入学生的姓名:"); + scanf("%s",s[i].name); + printf("输入学生的C语言成绩:"); + scanf("%f",&s[i].cscore); + printf("输入添加成绩的时间:"); + 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全部的学生信息:\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("输入1表示用学号修改,输入2表示用姓名修改!请选择:\n"); + scanf("%d",&x); + if(x==1) + { + printf("请输入修改成绩人的学号;");scanf("%d",&num); + for(i=0;i=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到89分学生的信息!\n"); + for(i=0;i=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到79分学生的信息!\n"); + for(i=0;i=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