1、 printf(Input student number(nN | n 1) return 0; else /主程序 while(con != 0) /输出 printf(nManagement for Students scoresn1.Append recordn2.Calculate total and average score of every coursen3.Calculate total and average score of every studentn4.Sort in descending order by total score of every studentn5.
2、Sort in ascending order by total score of every studentn6.Sort in ascending order by numbern7.Sort in dictionary order by namen8.Search by numbern9.Search by namen10.Statistic analysisn11.List recordn12.Write to a filen13.Read from a filen0.Exitn / 录入学生的人数:Please Input your choice: scanf(con); / 录入每
3、个学生的学号、姓名和各科成绩: if(con = 1) printf(Input students ID,name and score:n for(i = 0; i n; i+) scanf(%ld, &stui.id); getchar(); fgets(stui.name, sizeof(stui.name), stdin);/有问题!%f %f %fstui.score0, &stui.score1, &stui.score2); / 计算每门课程的总分和平均分: else if(con = 2) addc(stu, n); / 计算每个学生各门课程的总分和平均分: else if(co
4、n = 3) adds(stu, n); / 按总成绩由高到低排出名次表: else if(con = 4)Sort in descending order by total score of every student:NOtNametMTtENtPHtSUMtAVERn pxs(stu, ds, n); / 按总成绩由低到高排出名次表: else if(con = 5)Sort in ascending order by total score of every student: pxs(stu, as, n); / 按学号由小到大排出成绩表: else if(con = 6)Sort i
5、n ascending order by number: pxi(stu, n); / 按姓名的字典顺序排出成绩表: else if(con = 7)Sort in dictionary order by name: pxn(stu, n); / 按学号查询学生排名、学号、姓名及其考试成绩: else if(con = 8) seai(stu, n); / 按姓名查询学生排名、学号、姓名及其考试成绩: else if(con = 9) sean(stu, n); / 按100,(90100)(8089)(7079)(6069)(059)统计各科每个类别的人数以及所占的百分比: else if(
6、con = 10) ana(stu, n); /输出信息 else if(con = 11) for(i=0;in;i+) printf(%ldt, stui.id); for(j=0;stui.namej!=n;j+) putchar(stui.namej); t%.0ft%.0ft%.0ft%.0ft%.0fn, stui.score0, stui.score1, stui.score2, stui.score3, (stui.score3/3); /写入文件 else if(con = 12) wri(stu, n); /读取文件 else if(con = 13) rea(stu, n
7、); else if(con = 0)End of program! elseInput error! return 0;void addc(struct student *pt, int n) int i, j; float sum; for(j=0;j3; sum = 0; for(i=0; sum += stui.scorej; printf(course %d:sum=%.0f,aver=%.0fn, (j+1), sum, (sum/n);void adds(struct student *pt, int n) int i; for(i=0; stui.score3 = stui.s
8、core0 + stui.score1 + stui.score2;student %d:, (i+1), stui.score3, (stui.score3/3);void pxs(struct student *pt, int (*comp)(float a, float b), int n) struct student temp; for(j=0;(n-i-1); if(*comp)(stuj.score3, stuj+1.score3) temp = stuj; stuj = stuj+1; stuj+1 = temp; putchar(stui.namej);int ds(floa
9、t a, float b) return avoid pxi(struct student *pt, int n) if(stuj.id stuj+1.id)void pxn(struct student *pt, int n) if(strcmp(stuj.name,stuj+1.name)0)void seai(struct student *pt, int n) int i, j, con=0; long id;Input the number you want to search:id); if(stuj.score3stuj+1.score3) if(stui.id=id)%dt%l
10、dt, (i+1), stui.id); for(j=0; con=1; break; if(con=0)Not found!void sean(struct student *pt, int n) char name10;Input the name you want to search: getchar(); fgets(name, sizeof(name), stdin); if(strcmp(stui.name, name)=0)void ana(struct student *pt, int n) int i, j, n1, n2, n3, n4, n5, n6; n1=0;n2=0
11、;n3=0;n4=0;n5=0;n6=0; if(stui.scorej60) n1+=1; else if(stui.scorej70) n2+=1;80) n3+=1;90) n4+=1;=100) n5+=1; if(stui.scorej=100) n6+=1;For course %d:, (j+1);60t%dt%.2f%n, n1, 100*(float)n1/n);%d-%dt%dt%.2f%n, 60, 69, n2, 100*(float)n2/n);, 70, 79, n3, 100*(float)n3/n);, 80, 89, n4, 100*(float)n4/n);
12、, 90, 100, n5, 100*(float)n5/n);%dt%dt%.2f%n, 100, n6, 100*(float)n6/n);void wri(STUDENT *pt, int n) FILE *fp; if(fp = fopen(student.txt, w) = NULL) exit(0); /fprintf(fp, fprintf(fp, fprintf(fp, %c, stui.namej); fclose(fp);save successfully!void rea(STUDENT *pt, int n) int m; long a; float c,d,e,f,g; char b10; /char head50;r exit(0); /fgets(head, 50, fp); /puts(head); for(m = 0; m m+) /printf(scjdbfdsdj fscanf(fp, a);, a);%10s, b);%st fscanf(fp, %fc);%.0ft, c);%fd);, d);e);, e);f);, f);g);%.0fn, g); /printf(jdhergjdkfnjherdgfdhbn
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1