源代码:
1 #include2 #include 3 #include 4 5 #define Score_Num 35 6 7 struct Standard 8 { 9 int A; 10 int B; 11 int C; 12 int D; 13 char Correct_Answer; 14 }; 15 16 struct Standard Standard_Answer[Score_Num];//记录标准答案 17 18 struct Stu 19 { 20 int Num;//学生学号 21 char Name[32];//学生姓名 22 char Answer[Score_Num];//准确答案 23 int Score;//学生分数 24 }; 25 26 struct Stu Student[100];//存储学生信息 27 int Stu_Num = 0;//存储学生数目 28 29 //---------------------------------统计标准答案------------------------ 30 void Standard_Num() 31 { 32 int i, j; 33 int tag; 34 for(i=0;i tag) 52 { 53 tag = Standard_Answer[j].B; 54 Standard_Answer[j].Correct_Answer = 'B'; 55 } 56 if(Standard_Answer[j].C > tag) 57 { 58 tag = Standard_Answer[j].C; 59 Standard_Answer[j].Correct_Answer = 'C'; 60 }if(Standard_Answer[j].D > tag) 61 { 62 tag = Standard_Answer[j].D; 63 Standard_Answer[j].Correct_Answer = 'D'; 64 } 65 } 66 } 67 //---------------------------------统计标准答案------------------------ 68 69 70 71 //------------------实现每次从文本文件中读取一行----------------------- 72 char* Read_line(FILE* f, char* line) 73 { 74 75 return line; 76 } 77 //------------------实现每次从文本文件中读取一行----------------------- 78 79 //------------------打印标准答案--------------------------------------- 80 void Standard_Print() 81 { 82 int i; 83 for(i=0; i =0; i--)199 {200 printf("%d %s的成绩是%d\n", Student[i].Num, Student[i].Name, Student[i].Score);201 }202 }203 else204 {205 printf("按升序排列学生成绩:\n");206 for(i=0; i high)227 high = Student[i].Score;228 if(Student[i].Score < low)229 low = Student[i].Score;230 if(Student[i].Score >= 60)231 hege++;232 }233 avr = sum/Stu_Num;234 printf("最高分是:%d\n最低分是:%d\n平均分是:%f\n及格率是:%f\n", high, low, avr, hege*1.0/Stu_Num);235 }236 //----------------------------------试卷分析------------------------------237 238 239 int main()240 {241 int tag=1;242 Load_File();//从文件中读取学生信息243 Standard_Num();//统计标准答案244 Student_Score_Get();//计算每个学生的分数245 while(tag != 0)246 {247 tag = 0;248 printf("**************************************************************\n");249 printf("1.打印标准答案\n");250 printf("2.根据学生姓名查询学生信息\n");251 printf("3.按升序打印学生成绩\n");252 printf("4.按降序打印学生成绩\n");253 printf("5.打印统计信息\n");254 printf("0.退出系统\n");255 printf("请输入你要操作的序号:\n");256 printf("**************************************************************\n");257 scanf("%d", &tag);258 switch(tag)259 {260 case 1:Standard_Print();break;261 case 2:Student_Score_Look();break;262 case 3:Student_All_Score_Sort(0);break;263 case 4:Student_All_Score_Sort(1);break;264 case 5:Paper_Analyse();break;265 case 0:return 0;266 default:printf("输入错误!请从新输入:\n");267 }268 }269 return 0;270 }
测试文件:
1 1 赵光 CADADCDCDACCCDACCBCAAACCDBBCBDDBBAD 2 2 罗志 CADBDCBCDADCABACBCCACACCAABCBDDBCAB 3 3 闫谷凡 CDCBDCCCDBDBBBCCBBCACACBAABCBDDBCAB 4 4 黄智博 CDCBDCCCDBDDABACBDCACACAAABCBDDBCCA 5 5 汪昇朗 CACBDCBCDBDCBBACBDCACCCAAABCBDDBCAB 6 6 刘奋伦 CDDBDCDCDBDAABBDDBCBCACAAABCBDDBCAB 7 7 李磊鹏 CADBDABCDBDCABCCBDBACCCAABBCBDDBCAB 8 8 高卫 DADBDDBCDBDCBCCCBDCBCACBAABCBDDADAA 9 9 周鸿韵 CADBDCCBCADCBCDCABCCCACADBBCDCDBDAA10 10 杨建 CBDBDBBCDBDBBCCABDBACACBABBCBDAADAB11 11 李海凯 CADBDCACDBDCBDADDADABAACBBBCBDDBCAB12 12 李冲谱 CADBDCCCDBDCBBACBBCACACAABBCBDDBCAB13 13 邰杨敏 CACCDCBCDBDCBCCCBDCDCACABBBCBDDBCAB14 14 姚畅生 CBDBDCDDDBDCDCCBBDCDCCCADABCBDDACAA15 15 禤微 CADBDABCDCDCBBCBBDBACCAAABBCBDDBCAB16 16 丁宁 CADADCBCDBDCBDDCDCCABACABABCBDDBCDD17 17 乔梦进 CADDDABCDBDCBBCABDBACACBDBBCBDDBCAB18 18 张华 CADBDCBCDBDCBBCACDCACACAABBCBDDBCAB19 19 代怡康 CADBDABBDBDCBCDABDCBCCCAAABCBDDBCAB20 20 张文剑 CABDACCCDBDCBCCCBCDBCCABBDBBCCDBCCD21 21 吴汉 AADBACCCDBDABBCCBDCACACABABCBDDBCAB22 22 刘亚 CADBBABCDADBBCCADBBACACADABCBDDBCAB23 23 吴璐 CADBDBCCDBDCBBCCBCBACACAABBCBDDBCAB24 24 唐金 CACBDBACDBDBBCADDCCAAACBCABCBDDBCAB25 25 刘秋 CADCDABCDADCBCDADDBCCAAABBBCBDDBCAB26 26 徐文 CADBDDBCDBDCBBAABDBACCCADBBCBDDACAB27 27 孙育夫 CABDDCBCDBDCBBDCBDCAACCCDBBCBDDBCCA28 28 毛东 CDABDDBCDBDCBCCADDCACCCAABBCBDDBCAB29 29 陈环勇 CADBDABCDBDCBBACCABACCCAABBCBDDBCCB30 30 郑彪爽 CBDBCCDBBAACBADBCBDDAACCDBBCCDDBCAB31 31 赵志龙 CADBDDBCDBDABBDABDBACCCBAABCBDDBCAB32 32 梁傲朝 CADBDABCDBDBBBDCDDCACAAADBBCBDDBCAA33 33 许同雷 CADBDABCDBDABBBCBDCDCACAABBCBDDBCAB34 34 徐彦楠 CADBDCBCDBDCBBACDDCACCAABABCBDDBCAB35 35 罗建磊 CADBDCCCDBDCBCDADBCAACACBBBCBDDBBAD36 36 曾少林 CBDBDCBCBADDCCADDABACAABCBBCADDBAAB37 37 郭磊杰 CADBDBBCDACCABDCDDBBCAADBBBCBDDBCAD38 38 閤道炜 CADBDCBCDBDBADBCABDCCACABBBCBDDADCD39 39 胡风波 DADBDDBCDBDCBBCCBDBAACCABBBCBDDACAB40 40 张兆 CDDBDADCDBDCBCCDDDBACAACDBBCBDDBDAB41 41 吴雪 BDDBDCBCDBDCBDDCBDCACAAAABBCBDDBCCA42 42 卫曦群 CADBDDACDBDCBBCCDCCACCCAABBCBDDBCCA43 43 郭文雪 CBDBDDBCDBDBCCCCBBCACAAAABBCBBDBCCB44 44 黄甘亮 CBDBDCBCDBDBADBCDDCCAACADABCDDDBCBA45 45 苏子淇 CADBDCBCDBCCBCACADBACACDAABCBCDACCA46 46 王樊聪 CBDBDCBCDBDCABABBDCACCCAAABCBDDACAB47 47 肖勇杰 CADBDCBCDBDCBBCCBDCACCCAABBCBDDBCAB48 48 石小 CCDBDDCCDBDBBBCCCBCAAAADCBBCBDDBCAB49 49 刘大远 CADBDCCCDBDBADCCADCCCAAAAABCADDCCCA50 50 陈世怡 CADBDCCCDBDABCCCDDCAAAACAABCADDACCA51 51 王鹏康 CADBDCDCDCCACCDDBDCABAAACBBCBDDBCAB52 52 解欣琦 BBDBADCDDBACADBACBDDAADABABCACDBCAA53 53 刘周雯 CADBDCCCDBDCBCACBACACCCADABCBDDACAB54 54 代博涛 CADBDBBCDBDBBCDCDABDCCABBABCBDDACAB55 55 刘亚明 CADBDCDCDBDABBAABABACACAABBCBDDBCAB56 56 韩建昊 CADBDBBCDBDCBBCBBDBACCCAABBCBDDBCAB57 57 于磊思琪 CBDCDCCCDBDBBDCAACDACAAADBBBBDABCCA58 58 王治 DADBDBBCDBDCBBCABDBCCCCAABBCBDDBCAD59 59 刘春东 CADBDCBCDBDBBBCCADDACAAAAABCBDDBCAB60 60 魏恒宇 CACBDCBCDBDCBBDCBDBACACBABBCBCDBCAB61 61 陈春迪 CADBDCBCDBDCBBCCBBBACAABBBBCBDDBCCD62 62 贾汝远 CADBDBBCDBDBCADABDCBAACCBABCACDBCAB63 63 韩全彤 CADBDCBCDBDCBBCCBDBACACAABBCBDDCCAB64 64 付彬祺 CADBDCBCDADABBDCDDBACACBABBCBDDBCBB65 65 王泽文 CADBBCBCDBDACDBBBBCDBAADBBBCBCDACAB66 66 胡富南 CADBDCDCDACCBDCCCABACCCDBBBCBDDBCAB67 67 肖秋来 CADDDCBCDBCCBCACDCBABACCAABBBDDACCA68 68 周晓 CADBDABCDADCBCCDBDBACCCAABBCBDDBCAB69 69 王奕敏 CADBDCBCDBDCBBCABDBACCCAABBCBDDBCAB70 70 徐钰英 DADBDABCDBDCABCCBDBBCCCABBBCBDCBCAB71 71 陈赢 CDDBAABCBADABCCCDBCACACDAABCBDDBCAB72 72 杨君 CADBDDACCBDCBDDCBCCCCCCCCBBCBDDBCAB73 73 李清雪 DADBDCBCDBDCABDCBDCACCCAABBCBDDBCAB74 74 周俊蒙 CADBCDBCCCDCBDBCBCCACACBBBBCBDDACAB75 75 李梦 CACBDCBCDBDCBAACBDCACACCBABCBDDBCAB76 76 夏焕宏 CBDBDCCCDADABBDCBCCAACAADBBBBDDBCDD77 77 徐鑫强 CADBDCBCDBDAAADCBBCABACAABBCBDDBCAB78 78 娄克瑞 CACBDBBCCBDCBBDABACACAAAAABCBDABCAB79 79 董泽光 CDDCDABCDBDDBCDDDCBACACBBABCBDDBBCD80 80 黄念龙 CACBDABCDBDABBCCBDCACCCAABBCBDDBCAB81 81 林世 CADBDCBCDBDABAACBDBACCCAABBCBDDBCAB82 82 王雪 CADBDCBCDBDCBBCABDBACACAABBCBDDBCAB83 83 何璐 CADCDBBCDBDCCBACBDBCCACAABBCBDDBCAB84 84 吴一 CBDBDCACBBDCBCACBDCCCACADBBCBDDBCAB85 85 龚文杰 CADBDCBCDBDCBBCBBDCACCCBAABCBDDBCAB86 86 王志媛 DAABDCACDBDCCCCCBDCAAACCCABCACDBCCA87 87 段靖章 CADBDCBCDCDCBBDABDBACAACABBCBCDBCAB88 88 胡大 CADBDCCCDBDBBDDCBDDCCACAAABBBCDBCBB89 89 黄利伟 CADBDCBCDBDCABDCCDBACACCADBCBDDBCAB90 90 张文源 CADBDCBCDBDCBBDABDBACCCAABBCBDDBCAB91 91 林涛 CADBDBBCDBDCBBCABDBACCCAABBCBDDBCAB