C语言成绩管理系统(自动生成成绩)
算法大作业,也差不多算是一个C语言课设。这也是自己第一次认真一点点写出的代码,可能问题不少,但题目的要求也都达到了。
大作业要求:1、自动生成10个班,每个班50人的学生语数外成绩;
2、将学生成绩保存到磁盘,并且可从磁盘将学生成绩导出;
3、将群体学生按总分排名,按总分排名后,还能显示该学生语数外各科年级排名;
4、按班级将学生按总分排名,按总分排名后,还能显示该学生语数外各科年级排名。
由于程序本身也不是很复杂,所以程序整体框架可直接看函数声明:
************************************************************************************************************************************************************************
以下函数声明即为程序整体结构,帮助函数里是操作时的注意事项
//函数声明
float Randomly_Score(void); //随机生成分数
char* Randomly_generated_name(int f); //生成姓名
void Randomly_name_score(void); //生成学生信息
void all_add_score(struct STU_Score_information stu[],float preallscore[],int number); //合计总成绩
void Sort(struct STU_Score_information stu[], int number); //用冒泡排序法按照总分排序
void menu(void); //操作菜单
void help(void); //操作提示
void Ranking_grade_yuwen(float preYuwen[],int number,struct STU_Score_information stu[]); //语文成绩年级排名
void Ranking_grade_math(float preMath[],int number,struct STU_Score_information stu[]); //数学成绩年级排名
void Ranking_grade_English(float preEnglish[],int number,struct STU_Score_information stu[]); //英语成绩年级排名
void read(void); //从txt文件读取数据
void save(void);//将数据保存至txt文件
void help(void);//操作提示
void Exit(void);//退出整个程序
//帮助
void help(void){
printf(" ****************************************\n\n");
printf(" 1.输入对应的序号实现相应的功能。\n\n") ;
printf(" 2.在使用保存功能前必须有某个可以改变数据功能先工作,如想要保存三班成绩信息,就必须先使用显示三班成绩功能\n\n");
printf(" ****************************************\n\n");
}
*************************************************************************************************************************************************************************
后面就不多废话,直接上源码:
1 #include <stdio.h> 2 #include <string.h> 3 #include <stdlib.h> 4 5 6 //定义每个班人数和年级总人数 7 #define CLASS_NUMBER 50 8 #define GRADE_NUMBER 500 9 10 //声明存储学生信息的结构体 11 struct STU_Score_information{ 12 char* name[10]; 13 int student_ID; 14 float YuWen_Score; 15 float Math_Score; 16 float English_Score; 17 float all_score; 18 int allscore_Grade_ranking; 19 int allscore_Class_ranking; 20 int Yuwen_ranking; 21 int Math_ranking; 22 int English_ranking; 23 }; 24 25 //各班及年级个人总分存放数组 26 float preclass1_allscore[CLASS_NUMBER]; 27 float preclass2_allscore[CLASS_NUMBER]; 28 float preclass3_allscore[CLASS_NUMBER]; 29 float preclass4_allscore[CLASS_NUMBER]; 30 float preclass5_allscore[CLASS_NUMBER]; 31 float preclass6_allscore[CLASS_NUMBER]; 32 float preclass7_allscore[CLASS_NUMBER]; 33 float preclass8_allscore[CLASS_NUMBER]; 34 float preclass9_allscore[CLASS_NUMBER]; 35 float preclass10_allscore[CLASS_NUMBER]; 36 37 float pregrade_allscore[GRADE_NUMBER]; 38 39 //声明存放各科成绩的数组 40 float preYuwen[500]; 41 float preMath[500]; 42 float preEnglish[500]; 43 44 45 46 //声明结构体数组 ,存放年级及各班信息 47 struct STU_Score_information stu_Score_information[10][50]; 48 struct STU_Score_information stu_Score_information1[50]; 49 struct STU_Score_information stu_Score_information2[50]; 50 struct STU_Score_information stu_Score_information3[50]; 51 struct STU_Score_information stu_Score_information4[50]; 52 struct STU_Score_information stu_Score_information5[50]; 53 struct STU_Score_information stu_Score_information6[50]; 54 struct STU_Score_information stu_Score_information7[50]; 55 struct STU_Score_information stu_Score_information8[50]; 56 struct STU_Score_information stu_Score_information9[50]; 57 struct STU_Score_information stu_Score_information10[50]; 58 59 struct STU_Score_information stu_Score_information_grade[500]; 60 61 //声明相关全局变量 62 int m; 63 64 65 //函数声明 66 float Randomly_Score(void); //随机生成分数 67 char* Randomly_generated_name(int f); //生成姓名 68 void Randomly_name_score(void); //生成学生信息 69 void all_add_score(struct STU_Score_information stu[],float preallscore[],int number); //合计总成绩 70 void Sort(struct STU_Score_information stu[], int number); //用冒泡排序法按照总分排序 71 void menu(void); //操作菜单 72 void help(void); //操作提示 73 void Ranking_grade_yuwen(float preYuwen[],int number,struct STU_Score_information stu[]); //语文成绩年级排名 74 void Ranking_grade_math(float preMath[],int number,struct STU_Score_information stu[]); //数学成绩年级排名 75 void Ranking_grade_English(float preEnglish[],int number,struct STU_Score_information stu[]); //英语成绩年级排名 76 void read(void); //从txt文件读取数据 77 void save(void);//将数据保存至txt文件 78 void help(void);//操作提示 79 void Exit(void);//退出整个程序 80 81 82 int main(void){ 83 menu(); 84 return 0; 85 } 86 87 //自动生成姓名 88 char* Randomly_generated_name(int f){ 89 char* name[500] = { "赵二蛋","钱二蛋","孙二蛋","李二蛋","周二蛋","武二蛋","郑二蛋","王二蛋","冯二蛋","陈二蛋", 90 "赵铁柱","钱铁柱","孙铁柱","李铁柱","周铁柱","武铁柱","郑铁柱","王铁柱","冯铁柱","陈铁柱", 91 "赵欣竹","钱欣竹","孙欣竹","李欣竹","周欣竹","武欣竹","郑欣竹","王欣竹","冯欣竹","陈欣竹", 92 "赵观博","钱观博","孙观博","李观博","周观博","武观博","郑观博","王观博","冯观博","陈观博", 93 "赵诗含","钱诗含","孙诗含","李诗含","周诗含","武诗含","郑诗含","王诗含","冯诗含","陈诗含", 94 "褚二蛋","卫二蛋","蒋二蛋","沈二蛋","韩二蛋","杨二蛋","秦二蛋","尤二蛋","许二蛋","何二蛋", 95 "褚铁柱","卫铁柱","蒋铁柱","沈铁柱","韩铁柱","杨铁柱","秦铁柱","尤铁柱","许铁柱","何铁柱", 96 "褚欣竹","卫欣竹","蒋欣竹","沈欣竹","韩欣竹","杨欣竹","秦欣竹","尤欣竹","许欣竹","何欣竹", 97 "褚观博","卫观博","蒋观博","沈观博","韩观博","杨观博","秦观博","尤观博","许观博","何观博", 98 "褚诗含","卫诗含","蒋诗含","沈诗含","韩诗含","杨诗含","秦诗含","尤诗含","许诗含","何诗含", 99 "吕二蛋","施二蛋","张二蛋","孔二蛋","曹二蛋","严二蛋","华二蛋","金二蛋","魏二蛋","陶二蛋", 100 "吕铁柱","施铁柱","张铁柱","孔铁柱","曹铁柱","严铁柱","华铁柱","金铁柱","魏铁柱","陶铁柱", 101 "吕欣竹","施欣竹","张欣竹","孔欣竹","曹欣竹","严欣竹","华欣竹","金欣竹","魏欣竹","陶欣竹", 102 "吕观博","施观博","张观博","孔观博","曹观博","严观博","华观博","金观博","魏观博","陶观博", 103 "吕诗含","施诗含","张诗含","孔诗含","曹诗含","严诗含","华诗含","金诗含","魏诗含","陶诗含", 104 "姜二蛋","戚二蛋","谢二蛋","邹二蛋","喻二蛋","柏二蛋","水二蛋","窦二蛋","章二蛋","云二蛋", 105 "姜铁柱","戚铁柱","谢铁柱","邹铁柱","喻铁柱","柏铁柱","水铁柱","窦铁柱","章铁柱","云铁柱", 106 "姜欣竹","戚欣竹","谢欣竹","邹欣竹","喻欣竹","柏欣竹","水欣竹","窦欣竹","章欣竹","云欣竹", 107 "姜观博","戚观博","谢观博","邹观博","喻观博","柏观博","水观博","窦观博","章观博","云观博", 108 "姜诗含","戚诗含","谢诗含","邹诗含","喻诗含","柏诗含","水诗含","窦诗含","章诗含","云诗含", 109 "苏二蛋","潘二蛋","葛二蛋","奚二蛋","范二蛋","彭二蛋","郎二蛋","鲁二蛋","韦二蛋","昌二蛋", 110 "苏铁柱","潘铁柱","葛铁柱","奚铁柱","范铁柱","彭铁柱","郎铁柱","鲁铁柱","韦铁柱","昌铁柱", 111 "苏欣竹","潘欣竹","葛欣竹","奚欣竹","范欣竹","彭欣竹","郎欣竹","鲁欣竹","韦欣竹","昌欣竹", 112 "苏观博","潘观博","葛观博","奚观博","范观博","彭观博","郎观博","鲁观博","韦观博","昌观博", 113 "苏诗含","潘诗含","葛诗含","奚诗含","范诗含","彭诗含","郎诗含","鲁诗含","韦诗含","昌诗含", 114 "马二蛋","苗二蛋","风二蛋","花二蛋","方二蛋","俞二蛋","任二蛋","袁二蛋","柳二蛋","鲍二蛋", 115 "马铁柱","苗铁柱","风铁柱","花铁柱","方铁柱","俞铁柱","任铁柱","袁铁柱","柳铁柱","鲍铁柱", 116 "马欣竹","苗欣竹","风欣竹","花欣竹","方欣竹","俞欣竹","任欣竹","袁欣竹","柳欣竹","鲍欣竹", 117 "马观博","苗观博","风观博","花观博","方观博","俞观博","任观博","袁观博","柳观博","鲍观博", 118 "马诗含","苗诗含","风诗含","花诗含","方诗含","俞诗含","任诗含","袁诗含","柳诗含","鲍诗含", 119 "史二蛋","唐二蛋","费二蛋","廉二蛋","岑二蛋","薛二蛋","雷二蛋","贺二蛋","倪二蛋","汤二蛋", 120 "史铁柱","唐铁柱","费铁柱","廉铁柱","岑铁柱","薛铁柱","雷铁柱","贺铁柱","倪铁柱","汤铁柱", 121 "史欣竹","唐欣竹","费欣竹","廉欣竹","岑欣竹","薛欣竹","雷欣竹","贺欣竹","倪欣竹","汤欣竹", 122 "史观博","唐观博","费观博","廉观博","岑观博","薛观博","雷观博","贺观博","倪观博","汤观博", 123 "史诗含","唐诗含","费诗含","廉诗含","岑诗含","薛诗含","雷诗含","贺诗含","倪诗含","汤诗含", 124 "滕二蛋","殷二蛋","罗二蛋","毕二蛋","赫二蛋","安二蛋","常二蛋","乐二蛋","于二蛋","时二蛋", 125 "滕铁柱","殷铁柱","罗铁柱","毕铁柱","赫铁柱","安铁柱","常铁柱","乐铁柱","于铁柱","时铁柱", 126 "滕欣竹","殷欣竹","罗欣竹","毕欣竹","赫欣竹","安欣竹","常欣竹","乐欣竹","于欣竹","时欣竹", 127 "滕观博","殷观博","罗观博","毕观博","赫观博","安观博","常观博","乐观博","于观博","时观博", 128 "滕诗含","殷诗含","罗诗含","毕诗含","赫诗含","安诗含","常诗含","乐诗含","于诗含","时诗含", 129 "傅二蛋","皮二蛋","齐二蛋","康二蛋","伍二蛋","余二蛋","元二蛋","卜二蛋","顾二蛋","孟二蛋", 130 "傅铁柱","皮铁柱","齐铁柱","康铁柱","伍铁柱","余铁柱","元铁柱","卜铁柱","顾铁柱","孟铁柱", 131 "傅欣竹","皮欣竹","齐欣竹","康欣竹","伍欣竹","余欣竹","元欣竹","卜欣竹","顾欣竹","孟欣竹", 132 "傅观博","皮观博","齐观博","康观博","伍观博","余观博","元观博","卜观博","顾观博","孟观博", 133 "傅诗含","皮诗含","齐诗含","康诗含","伍诗含","余诗含","元诗含","卜诗含","顾诗含","孟诗含", 134 "平二蛋","黄二蛋","和二蛋","穆二蛋","萧二蛋","尹二蛋","姚二蛋","邵二蛋","湛二蛋","汪二蛋", 135 "平铁柱","黄铁柱","和铁柱","穆铁柱","萧铁柱","尹铁柱","姚铁柱","邵铁柱","湛铁柱","汪铁柱", 136 "平欣竹","黄欣竹","和欣竹","穆欣竹","萧欣竹","尹欣竹","姚欣竹","邵欣竹","湛欣竹","汪欣竹", 137 "平观博","黄观博","和观博","穆观博","萧观博","尹观博","姚观博","邵观博","湛观博","汪观博", 138 "平诗含","黄诗含","和诗含","穆诗含","萧诗含","尹诗含","姚诗含","邵诗含","湛诗含","汪诗含" 139 }; 140 char* name_get[10]; 141 strcpy(name_get,name[f]); 142 return name_get; 143 } 144 145 //自动生成随机分数 146 float Randomly_Score(void){ 147 float a; 148 a = rand() % ( 100 - 60 + 1 ) * 1.0 + 60.0; 149 return a; 150 } 151 152 153 //随机生成10个班的学生成绩信息,共500人 154 void Randomly_name_score(void){ 155 int i,j; 156 int f = 0; 157 158 for(i = 0;i<10;i++){ 159 for(j = 0;j<50;j++){ 160 strcpy(stu_Score_information[i][j].name,Randomly_generated_name(f)); 161 stu_Score_information[i][j].YuWen_Score = Randomly_Score(); 162 stu_Score_information[i][j].Math_Score = Randomly_Score(); 163 stu_Score_information[i][j].English_Score = Randomly_Score(); 164 // printf("%d班%d号:%s ,%1.3f ,%1.3f ,%1.3f \r\n",i+1,j+1,stu_Score_information[i][j].name,stu_Score_information[i][j].YuWen_Score, 165 // stu_Score_information[i][j].Math_Score,stu_Score_information[i][j].English_Score); 166 stu_Score_information[i][j].student_ID = f + 1000; 167 strcpy(stu_Score_information_grade[f].name,stu_Score_information[i][j].name); 168 stu_Score_information_grade[f].student_ID = stu_Score_information[i][j].student_ID; 169 170 stu_Score_information_grade[f].YuWen_Score = stu_Score_information[i][j].YuWen_Score; 171 preYuwen[f] = stu_Score_information[i][j].YuWen_Score; 172 stu_Score_information_grade[f].Math_Score = stu_Score_information[i][j].Math_Score; 173 preMath[f] = stu_Score_information[i][j].Math_Score; 174 stu_Score_information_grade[f].English_Score = stu_Score_information[i][j].English_Score; 175 preEnglish[f] = stu_Score_information[i][j].English_Score; 176 f++; 177 } 178 } 179 180 if(f == 499){ 181 f = 0; 182 } 183 184 for(i = 0;i<CLASS_NUMBER;i++){ 185 strcpy(stu_Score_information1[i].name,stu_Score_information[0][i].name); 186 stu_Score_information1[i].student_ID = stu_Score_information[0][i].student_ID; 187 stu_Score_information1[i].YuWen_Score = stu_Score_information[0][i].YuWen_Score; 188 stu_Score_information1[i].Math_Score = stu_Score_information[0][i].Math_Score; 189 stu_Score_information1[i].English_Score = stu_Score_information[0][i].English_Score; 190 191 strcpy(stu_Score_information2[i].name,stu_Score_information[1][i].name); 192 stu_Score_information2[i].student_ID = stu_Score_information[1][i].student_ID; 193 stu_Score_information2[i].YuWen_Score = stu_Score_information[1][i].YuWen_Score; 194 stu_Score_information2[i].Math_Score = stu_Score_information[1][i].Math_Score; 195 stu_Score_information2[i].English_Score = stu_Score_information[1][i].English_Score; 196 197 strcpy(stu_Score_information3[i].name,stu_Score_information[2][i].name); 198 stu_Score_information3[i].student_ID = stu_Score_information[2][i].student_ID; 199 stu_Score_information3[i].YuWen_Score = stu_Score_information[2][i].YuWen_Score; 200 stu_Score_information3[i].Math_Score = stu_Score_information[2][i].Math_Score; 201 stu_Score_information3[i].English_Score = stu_Score_information[2][i].English_Score; 202 203 strcpy(stu_Score_information4[i].name,stu_Score_information[3][i].name); 204 stu_Score_information4[i].student_ID = stu_Score_information[3][i].student_ID; 205 stu_Score_information4[i].YuWen_Score = stu_Score_information[3][i].YuWen_Score; 206 stu_Score_information4[i].Math_Score = stu_Score_information[3][i].Math_Score; 207 stu_Score_information4[i].English_Score = stu_Score_information[3][i].English_Score; 208 209 strcpy(stu_Score_information5[i].name,stu_Score_information[4][i].name); 210 stu_Score_information5[i].student_ID = stu_Score_information[4][i].student_ID; 211 stu_Score_information5[i].YuWen_Score = stu_Score_information[4][i].YuWen_Score; 212 stu_Score_information5[i].Math_Score = stu_Score_information[4][i].Math_Score; 213 stu_Score_information5[i].English_Score = stu_Score_information[4][i].English_Score; 214 215 strcpy(stu_Score_information6[i].name,stu_Score_information[5][i].name); 216 stu_Score_information6[i].student_ID = stu_Score_information[5][i].student_ID; 217 stu_Score_information6[i].YuWen_Score = stu_Score_information[5][i].YuWen_Score; 218 stu_Score_information6[i].Math_Score = stu_Score_information[5][i].Math_Score; 219 stu_Score_information6[i].English_Score = stu_Score_information[5][i].English_Score; 220 221 strcpy(stu_Score_information7[i].name,stu_Score_information[6][i].name); 222 stu_Score_information7[i].student_ID = stu_Score_information[6][i].student_ID; 223 stu_Score_information7[i].YuWen_Score = stu_Score_information[6][i].YuWen_Score; 224 stu_Score_information7[i].Math_Score = stu_Score_information[6][i].Math_Score; 225 stu_Score_information7[i].English_Score = stu_Score_information[6][i].English_Score; 226 227 strcpy(stu_Score_information8[i].name,stu_Score_information[7][i].name); 228 stu_Score_information8[i].student_ID = stu_Score_information[7][i].student_ID; 229 stu_Score_information8[i].YuWen_Score = stu_Score_information[7][i].YuWen_Score; 230 stu_Score_information8[i].Math_Score = stu_Score_information[7][i].Math_Score; 231 stu_Score_information8[i].English_Score = stu_Score_information[7][i].English_Score; 232 233 strcpy(stu_Score_information9[i].name,stu_Score_information[8][i].name); 234 stu_Score_information9[i].student_ID = stu_Score_information[8][i].student_ID; 235 stu_Score_information9[i].YuWen_Score = stu_Score_information[8][i].YuWen_Score; 236 stu_Score_information9[i].Math_Score = stu_Score_information[8][i].Math_Score; 237 stu_Score_information9[i].English_Score = stu_Score_information[8][i].English_Score; 238 239 strcpy(stu_Score_information10[i].name,stu_Score_information[9][i].name); 240 stu_Score_information10[i].student_ID = stu_Score_information[9][i].student_ID; 241 stu_Score_information10[i].YuWen_Score = stu_Score_information[9][i].YuWen_Score; 242 stu_Score_information10[i].Math_Score = stu_Score_information[9][i].Math_Score; 243 stu_Score_information10[i].English_Score = stu_Score_information[9][i].English_Score; 244 245 } 246 247 248 249 } 250 251 //合计每位同学的总分 252 void all_add_score(struct STU_Score_information stu[],float preallscore[],int number){ 253 int i; 254 for(i = 0;i<number;i++){ 255 preallscore[i] = stu[i].YuWen_Score + stu[i].Math_Score + stu[i].English_Score; 256 stu[i].all_score = stu[i].YuWen_Score + stu[i].Math_Score + stu[i].English_Score; 257 } 258 } 259 260 //用冒泡排序按总分进行排名 261 void Sort(struct STU_Score_information stu[], int number){ 262 int i,j; 263 float AllscoreFlag = -1; 264 float AllscoreFlagValue = -1; 265 int q = 1; 266 for(i = 0; i < number-1 ; i++){ 267 for(j = 0; j < number-i-1 ;j++){ 268 if(stu[j].all_score<stu[j+1].all_score){ 269 struct STU_Score_information temp = stu[j+1]; 270 stu[j+1] = stu[j]; 271 stu[j] = temp; 272 } 273 } 274 } 275 if(number==500){ 276 for(i=0;i<number;i++){ 277 if(stu[i].all_score == AllscoreFlagValue){ 278 stu[i].allscore_Grade_ranking = AllscoreFlag; 279 }else{ 280 stu[i].allscore_Grade_ranking = q; 281 q++; 282 } 283 if(stu[i].all_score != AllscoreFlagValue){ 284 AllscoreFlagValue = stu[i].all_score; 285 AllscoreFlag = stu[i].allscore_Grade_ranking; 286 } 287 288 } 289 } 290 if(number==50){ 291 for(i=0;i<number;i++){ 292 if(stu[i].all_score == AllscoreFlagValue){ 293 stu[i].allscore_Grade_ranking = AllscoreFlag; 294 }else{ 295 stu[i].allscore_Grade_ranking = q; 296 q++; 297 } 298 if(stu[i].all_score != AllscoreFlagValue){ 299 AllscoreFlagValue = stu[i].all_score; 300 AllscoreFlag = stu[i].allscore_Grade_ranking; 301 } 302 303 } 304 } 305 306 } 307 308 //获取语文年级排名 309 //void Ranking_grade_yuwen(float preYuwen[],int number,struct STU_Score_information stu[],struct STU_Score_information stu2[]){ 310 void Ranking_grade_yuwen(float preYuwen[],int number,struct STU_Score_information stu[]){ 311 int i,j; 312 float temp; 313 float YuwenFlag = -1; 314 float YuwenFlagValue = -1; 315 int q = 1; 316 for(i = 0; i < number-1 ; i++){ 317 for(j = 0; j < number-i-1 ;j++){ 318 if(preYuwen[j]<preYuwen[j+1]){ 319 temp = preYuwen[j+1]; 320 preYuwen[j+1] = preYuwen[j]; 321 preYuwen[j] = temp; 322 } 323 } 324 } 325 for(i=0;i < number;i++){ 326 for(j=0;j < number;j++){ 327 if(stu[j].YuWen_Score == preYuwen[i]){ 328 // stu[j].Yuwen_ranking = i; 329 if(preYuwen[i] == YuwenFlagValue){ 330 stu[j].Yuwen_ranking = YuwenFlag; 331 // stu2[j].Yuwen_ranking = YuwenFlag; 332 }else{ 333 stu[j].Yuwen_ranking = q; 334 // stu2[j].Yuwen_ranking = q; 335 q++; 336 } 337 338 if(preYuwen[i] != YuwenFlagValue){ 339 YuwenFlagValue = preYuwen[i]; 340 YuwenFlag = stu[j].Yuwen_ranking; 341 } 342 } 343 } 344 } 345 } 346 347 //获取数学年级排名 348 //void Ranking_grade_math(float preMath[],int number,struct STU_Score_information stu[],struct STU_Score_information stu2[]){ 349 void Ranking_grade_math(float preMath[],int number,struct STU_Score_information stu[]){ 350 int i,j; 351 float temp; 352 float MathFlag = -1; 353 float MathFlagValue = -1; 354 int q = 1; 355 for(i = 0; i < number-1 ; i++){ 356 for(j = 0; j < number-i-1 ;j++){ 357 if(preMath[j]<preMath[j+1]){ 358 temp = preMath[j+1]; 359 preMath[j+1] = preMath[j]; 360 preMath[j] = temp; 361 } 362 } 363 } 364 for(i=0;i < number;i++){ 365 for(j=0;j < number;j++){ 366 if(stu[j].Math_Score == preMath[i]){ 367 //stu[j].Math_ranking = i; 368 if(preMath[i] == MathFlagValue){ 369 stu[j].Math_ranking = MathFlag; 370 // stu2[j].Math_ranking = MathFlag; 371 }else{ 372 stu[j].Math_ranking = q; 373 // stu2[j].Math_ranking = q; 374 q++; 375 } 376 377 if(preMath[i] != MathFlagValue){ 378 MathFlagValue = preMath[i]; 379 MathFlag = stu[j].Math_ranking; 380 } 381 } 382 } 383 } 384 385 } 386 387 //获取英语年级排名 388 //void Ranking_grade_English(float preEnglish[],int number,struct STU_Score_information stu[],struct STU_Score_information stu2[]){ 389 void Ranking_grade_English(float preEnglish[],int number,struct STU_Score_information stu[]){ 390 int i,j; 391 int q = 2; 392 float temp; 393 // float EnglishFlag[GRADE_NUMBER]; 394 float EnglishFlag = -1; 395 float EnglishFlagValue = -1; 396 for(i = 0; i < number-1 ; i++){ 397 for(j = 0; j < number-i-1 ;j++){ 398 if(preEnglish[j]<preEnglish[j+1]){ 399 temp = preEnglish[j+1]; 400 preEnglish[j+1] = preEnglish[j]; 401 preEnglish[j] = temp; 402 } 403 } 404 } 405 406 for(i=0;i < number;i++){ 407 for(j=0;j < number;j++){ 408 if(stu[j].English_Score == preEnglish[i]){ 409 if(preEnglish[i] == EnglishFlagValue){ 410 stu[j].English_ranking = EnglishFlag; 411 // stu2[j].English_ranking = EnglishFlag; 412 }else{ 413 stu[j].English_ranking = q; 414 // stu2[j].English_ranking = q; 415 q++; 416 } 417 418 if(preEnglish[i] != EnglishFlagValue){ 419 EnglishFlagValue = preEnglish[i]; 420 EnglishFlag = stu[j].English_ranking; 421 } 422 // printf("%dE:%d\n",q++,stu[j].English_ranking); 423 } 424 } 425 } 426 427 } 428 429 //操作界面 430 void interface(void){ 431 printf("\n\n\n"); 432 printf(" ******************操作界面*****************\n\n"); 433 printf(" ****1、自动生成10个班500名学生成绩信息*****\n\n"); 434 printf(" ****2、显示学生年级成绩排名名单************\n\n"); 435 printf(" ****3、显示学生班级成绩排名名单************\n\n"); 436 printf(" ****4、保存变动后的信息********************\n\n"); 437 printf(" ****5、读取磁盘信息************************\n\n"); 438 printf(" ****6、帮助********************************\n\n"); 439 printf(" ****7、退出********************************\n\n"); 440 } 441 442 443 //菜单 444 void menu(void){ 445 446 interface(); 447 448 int m,i,j; 449 float YuwenFlag; 450 float YuwenFlagValue; 451 float MathFlag; 452 float MathFlagValue; 453 float EnglishFlag; 454 float EnglishFlagValue; 455 int q1,q2,q3; 456 // int flag = 1; 457 while(1){ 458 printf(" 请输入你需要执行的功能的序号:"); 459 int key; 460 int key3; 461 int flag3 = 1; 462 scanf("%d",&key); 463 switch(key){ 464 case 1: 465 system("cls"); 466 Randomly_name_score(); 467 Ranking_grade_yuwen(preYuwen,GRADE_NUMBER,stu_Score_information_grade); 468 Ranking_grade_math(preMath,GRADE_NUMBER,stu_Score_information_grade); 469 Ranking_grade_English(preEnglish,GRADE_NUMBER,stu_Score_information_grade); 470 all_add_score(stu_Score_information_grade,pregrade_allscore,GRADE_NUMBER); 471 Sort(stu_Score_information_grade,GRADE_NUMBER); 472 473 interface(); 474 printf(" 自动生成学生成绩完毕!\n"); 475 break; 476 case 2: 477 system("cls"); 478 printf("姓名\t学号\t语文\t语文年级排名\t数学\t数学年级排名\t英语\t英语年级排名\t总分\t年级排名\n"); 479 for(m = 0;m < GRADE_NUMBER;m++){ 480 printf("%s\t%3d\t%1.3f\t%4d\t\t%1.3f\t%4d\t\t%1.3f\t%4d\t\t%1.3f\t%3d\r\n", 481 stu_Score_information_grade[m].name,stu_Score_information_grade[m].student_ID, 482 stu_Score_information_grade[m].YuWen_Score,stu_Score_information_grade[m].Yuwen_ranking, 483 stu_Score_information_grade[m].Math_Score,stu_Score_information_grade[m].Math_ranking , 484 stu_Score_information_grade[m].English_Score,stu_Score_information_grade[m].English_ranking, 485 stu_Score_information_grade[m].all_score,stu_Score_information_grade[m].allscore_Grade_ranking); 486 } 487 488 interface(); 489 490 break; 491 case 3: 492 system("cls"); 493 while(flag3){ 494 q1 = 1; 495 q2 = 1; 496 q3 = 1; 497 YuwenFlag = -1; 498 YuwenFlagValue = -1; 499 MathFlag = -1; 500 MathFlagValue = -1; 501 EnglishFlag = -1; 502 EnglishFlagValue = -1; 503 printf("请输入需要查看的班级序号(1~10),输入11退出至主菜单:"); 504 scanf("%d",&key3); 505 switch(key3){ 506 case 1: 507 //一班 508 system("cls"); 509 printf(" **************11801班成绩名单********************\n"); 510 all_add_score(stu_Score_information1,preclass1_allscore,CLASS_NUMBER); 511 Sort(stu_Score_information1,CLASS_NUMBER); 512 for(i=0;i < GRADE_NUMBER;i++){ 513 for(j=0;j < CLASS_NUMBER;j++){ 514 // if(strcmp(stu_Score_information1[j].name,stu_Score_information_grade[i].name) == 0){ 515 // stu_Score_information1[j].student_ID = stu_Score_information_grade[i].student_ID; 516 // } 517 if(stu_Score_information1[j].YuWen_Score == preYuwen[i]){ 518 // stu[j].Yuwen_ranking = i; 519 if(preYuwen[i] == YuwenFlagValue){ 520 stu_Score_information1[j].Yuwen_ranking = YuwenFlag; 521 // stu2[j].Yuwen_ranking = YuwenFlag; 522 }else{ 523 stu_Score_information1[j].Yuwen_ranking = q1; 524 // stu2[j].Yuwen_ranking = q; 525 q1++; 526 } 527 528 if(preYuwen[i] != YuwenFlagValue){ 529 YuwenFlagValue = preYuwen[i]; 530 YuwenFlag = stu_Score_information1[j].Yuwen_ranking; 531 } 532 } 533 } 534 } 535 for(i=0;i < GRADE_NUMBER;i++){ 536 for(j=0;j < CLASS_NUMBER;j++){ 537 if(stu_Score_information1[j].Math_Score == preMath[i]){ 538 // stu[j].Yuwen_ranking = i; 539 if(preMath[i] == MathFlagValue){ 540 stu_Score_information1[j].Math_ranking = MathFlag; 541 // stu2[j].Yuwen_ranking = YuwenFlag; 542 }else{ 543 stu_Score_information1[j].Math_ranking = q2; 544 // stu2[j].Yuwen_ranking = q; 545 q2++; 546 } 547 548 if(preMath[i] != MathFlagValue){ 549 MathFlagValue = preMath[i]; 550 MathFlag = stu_Score_information1[j].Math_ranking; 551 } 552 } 553 } 554 } 555 556 for(i=0;i < GRADE_NUMBER;i++){ 557 for(j=0;j < CLASS_NUMBER;j++){ 558 if(stu_Score_information1[j].English_Score == preEnglish[i]){ 559 // stu[j].Yuwen_ranking = i; 560 if(preEnglish[i] == EnglishFlagValue){ 561 stu_Score_information1[j].English_ranking = EnglishFlag; 562 // stu2[j].Yuwen_ranking = YuwenFlag; 563 }else{ 564 stu_Score_information1[j].English_ranking = q3; 565 // stu2[j].Yuwen_ranking = q; 566 q3++; 567 } 568 569 if(preEnglish[i] != EnglishFlagValue){ 570 EnglishFlagValue = preEnglish[i]; 571 EnglishFlag = stu_Score_information1[j].English_ranking; 572 } 573 } 574 } 575 } 576 printf("姓名\t班级\t学号\t语文\t语文年级排名\t数学\t数学年级排名\t英语\t英语年级排名\t总分\t班级排名\n"); 577 for(m = 0;m < CLASS_NUMBER;m++){ 578 printf("%s\t11801班\t%3d\t%1.3f\t%4d\t\t%1.3f\t%4d\t\t%1.3f\t%4d\t\t%1.3f\t%3d\r\n", 579 stu_Score_information1[m].name,stu_Score_information1[m].student_ID, 580 stu_Score_information1[m].YuWen_Score,stu_Score_information1[m].Yuwen_ranking, 581 stu_Score_information1[m].Math_Score,stu_Score_information1[m].Math_ranking, 582 stu_Score_information1[m].English_Score,stu_Score_information1[m].English_ranking, 583 stu_Score_information1[m].all_score,stu_Score_information1[m].allscore_Grade_ranking); 584 585 } 586 break; 587 case 2: 588 system("cls"); 589 printf(" **************11802班成绩名单********************\n"); 590 all_add_score(stu_Score_information2,preclass2_allscore,CLASS_NUMBER); 591 Sort(stu_Score_information2,CLASS_NUMBER); 592 for(i=0;i < GRADE_NUMBER;i++){ 593 for(j=0;j < CLASS_NUMBER;j++){ 594 // if(strcmp(stu_Score_information2[j].name,stu_Score_information_grade[i].name) == 0){ 595 // stu_Score_information2[j].student_ID = stu_Score_information_grade[i].student_ID; 596 // } 597 if(stu_Score_information2[j].YuWen_Score == preYuwen[i]){ 598 // stu[j].Yuwen_ranking = i; 599 if(preYuwen[i] == YuwenFlagValue){ 600 stu_Score_information2[j].Yuwen_ranking = YuwenFlag; 601 // stu2[j].Yuwen_ranking = YuwenFlag; 602 }else{ 603 stu_Score_information2[j].Yuwen_ranking = q1; 604 // stu2[j].Yuwen_ranking = q; 605 q1++; 606 } 607 608 if(preYuwen[i] != YuwenFlagValue){ 609 YuwenFlagValue = preYuwen[i]; 610 YuwenFlag = stu_Score_information2[j].Yuwen_ranking; 611 } 612 } 613 } 614 } 615 for(i=0;i < GRADE_NUMBER;i++){ 616 for(j=0;j < CLASS_NUMBER;j++){ 617 if(stu_Score_information2[j].Math_Score == preMath[i]){ 618 // stu[j].Yuwen_ranking = i; 619 if(preMath[i] == MathFlagValue){ 620 stu_Score_information2[j].Math_ranking = MathFlag; 621 // stu2[j].Yuwen_ranking = YuwenFlag; 622 }else{ 623 stu_Score_information2[j].Math_ranking = q2; 624 // stu2[j].Yuwen_ranking = q; 625 q2++; 626 } 627 628 if(preMath[i] != MathFlagValue){ 629 MathFlagValue = preMath[i]; 630 MathFlag = stu_Score_information2[j].Math_ranking; 631 } 632 } 633 } 634 } 635 636 for(i=0;i < GRADE_NUMBER;i++){ 637 for(j=0;j < CLASS_NUMBER;j++){ 638 if(stu_Score_information2[j].English_Score == preEnglish[i]){ 639 // stu[j].Yuwen_ranking = i; 640 if(preEnglish[i] == EnglishFlagValue){ 641 stu_Score_information2[j].English_ranking = EnglishFlag; 642 // stu2[j].Yuwen_ranking = YuwenFlag; 643 }else{ 644 stu_Score_information2[j].English_ranking = q3; 645 // stu2[j].Yuwen_ranking = q; 646 q3++; 647 } 648 649 if(preEnglish[i] != EnglishFlagValue){ 650 EnglishFlagValue = preEnglish[i]; 651 EnglishFlag = stu_Score_information2[j].English_ranking; 652 } 653 } 654 } 655 } 656 printf("姓名\t班级\t学号\t语文\t语文年级排名\t数学\t数学年级排名\t英语\t英语年级排名\t总分\t班级排名\n"); 657 for(m = 0;m < CLASS_NUMBER;m++){ 658 printf("%s\t11802班\t%3d\t%1.3f\t%4d\t\t%1.3f\t%4d\t\t%1.3f\t%4d\t\t%1.3f\t%3d\r\n", 659 stu_Score_information2[m].name,stu_Score_information2[m].student_ID, 660 stu_Score_information2[m].YuWen_Score,stu_Score_information2[m].Yuwen_ranking, 661 stu_Score_information2[m].Math_Score,stu_Score_information2[m].Math_ranking, 662 stu_Score_information2[m].English_Score,stu_Score_information2[m].English_ranking, 663 stu_Score_information2[m].all_score,stu_Score_information2[m].allscore_Grade_ranking); 664 665 } 666 break; 667 case 3: 668 system("cls"); 669 printf(" **************11803班成绩名单********************\n"); 670 all_add_score(stu_Score_information3,preclass3_allscore,CLASS_NUMBER); 671 Sort(stu_Score_information3,CLASS_NUMBER); 672 for(i=0;i < GRADE_NUMBER;i++){ 673 for(j=0;j < CLASS_NUMBER;j++){ 674 // if(strcmp(stu_Score_information3[j].name,stu_Score_information_grade[i].name) == 0){ 675 // stu_Score_information3[j].student_ID = stu_Score_information_grade[i].student_ID; 676 // } 677 if(stu_Score_information3[j].YuWen_Score == preYuwen[i]){ 678 // stu[j].Yuwen_ranking = i; 679 if(preYuwen[i] == YuwenFlagValue){ 680 stu_Score_information3[j].Yuwen_ranking = YuwenFlag; 681 // stu2[j].Yuwen_ranking = YuwenFlag; 682 }else{ 683 stu_Score_information3[j].Yuwen_ranking = q1; 684 // stu2[j].Yuwen_ranking = q; 685 q1++; 686 } 687 688 if(preYuwen[i] != YuwenFlagValue){ 689 YuwenFlagValue = preYuwen[i]; 690 YuwenFlag = stu_Score_information3[j].Yuwen_ranking; 691 } 692 } 693 } 694 } 695 for(i=0;i < GRADE_NUMBER;i++){ 696 for(j=0;j < CLASS_NUMBER;j++){ 697 if(stu_Score_information3[j].Math_Score == preMath[i]){ 698 // stu[j].Yuwen_ranking = i; 699 if(preMath[i] == MathFlagValue){ 700 stu_Score_information3[j].Math_ranking = MathFlag; 701 // stu2[j].Yuwen_ranking = YuwenFlag; 702 }else{ 703 stu_Score_information3[j].Math_ranking = q2; 704 // stu2[j].Yuwen_ranking = q; 705 q2++; 706 } 707 708 if(preMath[i] != MathFlagValue){ 709 MathFlagValue = preMath[i]; 710 MathFlag = stu_Score_information3[j].Math_ranking; 711 } 712 } 713 } 714 } 715 716 for(i=0;i < GRADE_NUMBER;i++){ 717 for(j=0;j < CLASS_NUMBER;j++){ 718 if(stu_Score_information3[j].English_Score == preEnglish[i]){ 719 // stu[j].Yuwen_ranking = i; 720 if(preEnglish[i] == EnglishFlagValue){ 721 stu_Score_information3[j].English_ranking = EnglishFlag; 722 // stu2[j].Yuwen_ranking = YuwenFlag; 723 }else{ 724 stu_Score_information3[j].English_ranking = q3; 725 // stu2[j].Yuwen_ranking = q; 726 q3++; 727 } 728 729 if(preEnglish[i] != EnglishFlagValue){ 730 EnglishFlagValue = preEnglish[i]; 731 EnglishFlag = stu_Score_information3[j].English_ranking; 732 } 733 } 734 } 735 } 736 737 printf("姓名\t班级\t学号\t语文\t语文年级排名\t数学\t数学年级排名\t英语\t英语年级排名\t总分\t班级排名\n"); 738 for(m = 0;m < CLASS_NUMBER;m++){ 739 printf("%s\t11803班\t%3d\t%1.3f\t%4d\t\t%1.3f\t%4d\t\t%1.3f\t%4d\t\t%1.3f\t%3d\r\n", 740 stu_Score_information3[m].name,stu_Score_information3[m].student_ID, 741 stu_Score_information3[m].YuWen_Score,stu_Score_information3[m].Yuwen_ranking, 742 stu_Score_information3[m].Math_Score,stu_Score_information3[m].Math_ranking, 743 stu_Score_information3[m].English_Score,stu_Score_information3[m].English_ranking, 744 stu_Score_information3[m].all_score,stu_Score_information3[m].allscore_Grade_ranking); 745 746 } 747 break; 748 case 4: 749 system("cls"); 750 printf(" **************11804班成绩名单********************\n"); 751 all_add_score(stu_Score_information4,preclass4_allscore,CLASS_NUMBER); 752 Sort(stu_Score_information4,CLASS_NUMBER); 753 for(i=0;i < GRADE_NUMBER;i++){ 754 for(j=0;j < CLASS_NUMBER;j++){ 755 // if(strcmp(stu_Score_information4[j].name,stu_Score_information_grade[i].name) == 0){ 756 // stu_Score_information4[j].student_ID = stu_Score_information_grade[i].student_ID; 757 // } 758 if(stu_Score_information4[j].YuWen_Score == preYuwen[i]){ 759 // stu[j].Yuwen_ranking = i; 760 if(preYuwen[i] == YuwenFlagValue){ 761 stu_Score_information4[j].Yuwen_ranking = YuwenFlag; 762 // stu2[j].Yuwen_ranking = YuwenFlag; 763 }else{ 764 stu_Score_information4[j].Yuwen_ranking = q1; 765 // stu2[j].Yuwen_ranking = q; 766 q1++; 767 } 768 769 if(preYuwen[i] != YuwenFlagValue){ 770 YuwenFlagValue = preYuwen[i]; 771 YuwenFlag = stu_Score_information4[j].Yuwen_ranking; 772 } 773 } 774 } 775 } 776 for(i=0;i < GRADE_NUMBER;i++){ 777 for(j=0;j < CLASS_NUMBER;j++){ 778 if(stu_Score_information4[j].Math_Score == preMath[i]){ 779 // stu[j].Yuwen_ranking = i; 780 if(preMath[i] == MathFlagValue){ 781 stu_Score_information4[j].Math_ranking = MathFlag; 782 // stu2[j].Yuwen_ranking = YuwenFlag; 783 }else{ 784 stu_Score_information4[j].Math_ranking = q2; 785 // stu2[j].Yuwen_ranking = q; 786 q2++; 787 } 788 789 if(preMath[i] != MathFlagValue){ 790 MathFlagValue = preMath[i]; 791 MathFlag = stu_Score_information4[j].Math_ranking; 792 } 793 } 794 } 795 } 796 797 for(i=0;i < GRADE_NUMBER;i++){ 798 for(j=0;j < CLASS_NUMBER;j++){ 799 if(stu_Score_information4[j].English_Score == preEnglish[i]){ 800 // stu[j].Yuwen_ranking = i; 801 if(preEnglish[i] == EnglishFlagValue){ 802 stu_Score_information4[j].English_ranking = EnglishFlag; 803 // stu2[j].Yuwen_ranking = YuwenFlag; 804 }else{ 805 stu_Score_information4[j].English_ranking = q3; 806 // stu2[j].Yuwen_ranking = q; 807 q3++; 808 } 809 810 if(preEnglish[i] != EnglishFlagValue){ 811 EnglishFlagValue = preEnglish[i]; 812 EnglishFlag = stu_Score_information4[j].English_ranking; 813 } 814 } 815 } 816 } 817 818 printf("姓名\t班级\t学号\t语文\t语文年级排名\t数学\t数学年级排名\t英语\t英语年级排名\t总分\t班级排名\n"); 819 for(m = 0;m < CLASS_NUMBER;m++){ 820 printf("%s\t11804班\t%3d\t%1.3f\t%4d\t\t%1.3f\t%4d\t\t%1.3f\t%4d\t\t%1.3f\t%3d\r\n", 821 stu_Score_information4[m].name,stu_Score_information4[m].student_ID, 822 stu_Score_information4[m].YuWen_Score,stu_Score_information4[m].Yuwen_ranking, 823 stu_Score_information4[m].Math_Score,stu_Score_information4[m].Math_ranking, 824 stu_Score_information4[m].English_Score,stu_Score_information4[m].English_ranking, 825 stu_Score_information4[m].all_score,stu_Score_information4[m].allscore_Grade_ranking); 826 827 } 828 break; 829 case 5: 830 system("cls"); 831 printf(" **************11805班成绩名单********************\n"); 832 all_add_score(stu_Score_information5,preclass5_allscore,CLASS_NUMBER); 833 Sort(stu_Score_information5,CLASS_NUMBER); 834 for(i=0;i < GRADE_NUMBER;i++){ 835 for(j=0;j < CLASS_NUMBER;j++){ 836 // if(strcmp(stu_Score_information5[j].name,stu_Score_information_grade[i].name) == 0){ 837 // stu_Score_information5[j].student_ID = stu_Score_information_grade[i].student_ID; 838 // } 839 if(stu_Score_information5[j].YuWen_Score == preYuwen[i]){ 840 // stu[j].Yuwen_ranking = i; 841 if(preYuwen[i] == YuwenFlagValue){ 842 stu_Score_information5[j].Yuwen_ranking = YuwenFlag; 843 // stu2[j].Yuwen_ranking = YuwenFlag; 844 }else{ 845 stu_Score_information5[j].Yuwen_ranking = q1; 846 // stu2[j].Yuwen_ranking = q; 847 q1++; 848 } 849 850 if(preYuwen[i] != YuwenFlagValue){ 851 YuwenFlagValue = preYuwen[i]; 852 YuwenFlag = stu_Score_information5[j].Yuwen_ranking; 853 } 854 } 855 } 856 } 857 for(i=0;i < GRADE_NUMBER;i++){ 858 for(j=0;j < CLASS_NUMBER;j++){ 859 if(stu_Score_information5[j].Math_Score == preMath[i]){ 860 // stu[j].Yuwen_ranking = i; 861 if(preMath[i] == MathFlagValue){ 862 stu_Score_information5[j].Math_ranking = MathFlag; 863 // stu2[j].Yuwen_ranking = YuwenFlag; 864 }else{ 865 stu_Score_information5[j].Math_ranking = q2; 866 // stu2[j].Yuwen_ranking = q; 867 q2++; 868 } 869 870 if(preMath[i] != MathFlagValue){ 871 MathFlagValue = preMath[i]; 872 MathFlag = stu_Score_information5[j].Math_ranking; 873 } 874 } 875 } 876 } 877 878 for(i=0;i < GRADE_NUMBER;i++){ 879 for(j=0;j < CLASS_NUMBER;j++){ 880 if(stu_Score_information5[j].English_Score == preEnglish[i]){ 881 // stu[j].Yuwen_ranking = i; 882 if(preEnglish[i] == EnglishFlagValue){ 883 stu_Score_information5[j].English_ranking = EnglishFlag; 884 // stu2[j].Yuwen_ranking = YuwenFlag; 885 }else{ 886 stu_Score_information5[j].English_ranking = q3; 887 // stu2[j].Yuwen_ranking = q; 888 q3++; 889 } 890 891 if(preEnglish[i] != EnglishFlagValue){ 892 EnglishFlagValue = preEnglish[i]; 893 EnglishFlag = stu_Score_information5[j].English_ranking; 894 } 895 } 896 } 897 } 898 899 printf("姓名\t班级\t学号\t语文\t语文年级排名\t数学\t数学年级排名\t英语\t英语年级排名\t总分\t班级排名\n"); 900 for(m = 0;m < CLASS_NUMBER;m++){ 901 printf("%s\t11805班\t%3d\t%1.3f\t%4d\t\t%1.3f\t%4d\t\t%1.3f\t%4d\t\t%1.3f\t%3d\r\n", 902 stu_Score_information5[m].name,stu_Score_information5[m].student_ID, 903 stu_Score_information5[m].YuWen_Score,stu_Score_information5[m].Yuwen_ranking, 904 stu_Score_information5[m].Math_Score,stu_Score_information5[m].Math_ranking, 905 stu_Score_information5[m].English_Score,stu_Score_information5[m].English_ranking, 906 stu_Score_information5[m].all_score,stu_Score_information5[m].allscore_Grade_ranking); 907 908 } 909 break; 910 case 6: 911 system("cls"); 912 printf(" **************11806班成绩名单********************\n"); 913 all_add_score(stu_Score_information6,preclass6_allscore,CLASS_NUMBER); 914 Sort(stu_Score_information6,CLASS_NUMBER); 915 for(i=0;i < GRADE_NUMBER;i++){ 916 for(j=0;j < CLASS_NUMBER;j++){ 917 // if(strcmp(stu_Score_information6[j].name,stu_Score_information_grade[i].name) == 0){ 918 // stu_Score_information6[j].student_ID = stu_Score_information_grade[i].student_ID; 919 // } 920 if(stu_Score_information6[j].YuWen_Score == preYuwen[i]){ 921 // stu[j].Yuwen_ranking = i; 922 if(preYuwen[i] == YuwenFlagValue){ 923 stu_Score_information6[j].Yuwen_ranking = YuwenFlag; 924 // stu2[j].Yuwen_ranking = YuwenFlag; 925 }else{ 926 stu_Score_information6[j].Yuwen_ranking = q1; 927 // stu2[j].Yuwen_ranking = q; 928 q1++; 929 } 930 931 if(preYuwen[i] != YuwenFlagValue){ 932 YuwenFlagValue = preYuwen[i]; 933 YuwenFlag = stu_Score_information6[j].Yuwen_ranking; 934 } 935 } 936 } 937 } 938 for(i=0;i < GRADE_NUMBER;i++){ 939 for(j=0;j < CLASS_NUMBER;j++){ 940 if(stu_Score_information6[j].Math_Score == preMath[i]){ 941 // stu[j].Yuwen_ranking = i; 942 if(preMath[i] == MathFlagValue){ 943 stu_Score_information6[j].Math_ranking = MathFlag; 944 // stu2[j].Yuwen_ranking = YuwenFlag; 945 }else{ 946 stu_Score_information6[j].Math_ranking = q2; 947 // stu2[j].Yuwen_ranking = q; 948 q2++; 949 } 950 951 if(preMath[i] != MathFlagValue){ 952 MathFlagValue = preMath[i]; 953 MathFlag = stu_Score_information6[j].Math_ranking; 954 } 955 } 956 } 957 } 958 959 for(i=0;i < GRADE_NUMBER;i++){ 960 for(j=0;j < CLASS_NUMBER;j++){ 961 if(stu_Score_information6[j].English_Score == preEnglish[i]){ 962 // stu[j].Yuwen_ranking = i; 963 if(preEnglish[i] == EnglishFlagValue){ 964 stu_Score_information6[j].English_ranking = EnglishFlag; 965 // stu2[j].Yuwen_ranking = YuwenFlag; 966 }else{ 967 stu_Score_information6[j].English_ranking = q3; 968 // stu2[j].Yuwen_ranking = q; 969 q3++; 970 } 971 972 if(preEnglish[i] != EnglishFlagValue){ 973 EnglishFlagValue = preEnglish[i]; 974 EnglishFlag = stu_Score_information6[j].English_ranking; 975 } 976 } 977 } 978 } 979 980 printf("姓名\t班级\t学号\t语文\t语文年级排名\t数学\t数学年级排名\t英语\t英语年级排名\t总分\t班级排名\n"); 981 for(m = 0;m < CLASS_NUMBER;m++){ 982 printf("%s\t11806班\t%3d\t%1.3f\t%4d\t\t%1.3f\t%4d\t\t%1.3f\t%4d\t\t%1.3f\t%3d\r\n", 983 stu_Score_information6[m].name,stu_Score_information6[m].student_ID, 984 stu_Score_information6[m].YuWen_Score,stu_Score_information6[m].Yuwen_ranking, 985 stu_Score_information6[m].Math_Score,stu_Score_information6[m].Math_ranking, 986 stu_Score_information6[m].English_Score,stu_Score_information6[m].English_ranking, 987 stu_Score_information6[m].all_score,stu_Score_information6[m].allscore_Grade_ranking); 988 989 } 990 break; 991 case 7: 992 system("cls"); 993 printf(" **************11807班成绩名单********************\n"); 994 all_add_score(stu_Score_information7,preclass7_allscore,CLASS_NUMBER); 995 Sort(stu_Score_information7,CLASS_NUMBER); 996 for(i=0;i < GRADE_NUMBER;i++){ 997 for(j=0;j < CLASS_NUMBER;j++){ 998 // if(strcmp(stu_Score_information7[j].name,stu_Score_information_grade[i].name) == 0){ 999 // stu_Score_information7[j].student_ID = stu_Score_information_grade[i].student_ID; 1000 // } 1001 if(stu_Score_information7[j].YuWen_Score == preYuwen[i]){ 1002 // stu[j].Yuwen_ranking = i; 1003 if(preYuwen[i] == YuwenFlagValue){ 1004 stu_Score_information7[j].Yuwen_ranking = YuwenFlag; 1005 // stu2[j].Yuwen_ranking = YuwenFlag; 1006 }else{ 1007 stu_Score_information7[j].Yuwen_ranking = q1; 1008 // stu2[j].Yuwen_ranking = q; 1009 q1++; 1010 } 1011 1012 if(preYuwen[i] != YuwenFlagValue){ 1013 YuwenFlagValue = preYuwen[i]; 1014 YuwenFlag = stu_Score_information7[j].Yuwen_ranking; 1015 } 1016 } 1017 } 1018 } 1019 for(i=0;i < GRADE_NUMBER;i++){ 1020 for(j=0;j < CLASS_NUMBER;j++){ 1021 if(stu_Score_information7[j].Math_Score == preMath[i]){ 1022 // stu[j].Yuwen_ranking = i; 1023 if(preMath[i] == MathFlagValue){ 1024 stu_Score_information7[j].Math_ranking = MathFlag; 1025 // stu2[j].Yuwen_ranking = YuwenFlag; 1026 }else{ 1027 stu_Score_information7[j].Math_ranking = q2; 1028 // stu2[j].Yuwen_ranking = q; 1029 q2++; 1030 } 1031 1032 if(preMath[i] != MathFlagValue){ 1033 MathFlagValue = preMath[i]; 1034 MathFlag = stu_Score_information7[j].Math_ranking; 1035 } 1036 } 1037 } 1038 } 1039 1040 for(i=0;i < GRADE_NUMBER;i++){ 1041 for(j=0;j < CLASS_NUMBER;j++){ 1042 if(stu_Score_information7[j].English_Score == preEnglish[i]){ 1043 // stu[j].Yuwen_ranking = i; 1044 if(preEnglish[i] == EnglishFlagValue){ 1045 stu_Score_information7[j].English_ranking = EnglishFlag; 1046 // stu2[j].Yuwen_ranking = YuwenFlag; 1047 }else{ 1048 stu_Score_information7[j].English_ranking = q3; 1049 // stu2[j].Yuwen_ranking = q; 1050 q3++; 1051 } 1052 1053 if(preEnglish[i] != EnglishFlagValue){ 1054 EnglishFlagValue = preEnglish[i]; 1055 EnglishFlag = stu_Score_information7[j].English_ranking; 1056 } 1057 } 1058 } 1059 } 1060 1061 printf("姓名\t班级\t学号\t语文\t语文年级排名\t数学\t数学年级排名\t英语\t英语年级排名\t总分\t班级排名\n"); 1062 for(m = 0;m < CLASS_NUMBER;m++){ 1063 printf("%s\t11807班\t%3d\t%1.3f\t%4d\t\t%1.3f\t%4d\t\t%1.3f\t%4d\t\t%1.3f\t%3d\r\n", 1064 stu_Score_information7[m].name,stu_Score_information7[m].student_ID, 1065 stu_Score_information7[m].YuWen_Score,stu_Score_information7[m].Yuwen_ranking, 1066 stu_Score_information7[m].Math_Score,stu_Score_information7[m].Math_ranking, 1067 stu_Score_information7[m].English_Score,stu_Score_information7[m].English_ranking, 1068 stu_Score_information7[m].all_score,stu_Score_information7[m].allscore_Grade_ranking); 1069 1070 } 1071 break; 1072 case 8: 1073 system("cls"); 1074 printf(" **************11808班成绩名单********************\n"); 1075 all_add_score(stu_Score_information8,preclass8_allscore,CLASS_NUMBER); 1076 Sort(stu_Score_information8,CLASS_NUMBER); 1077 for(i=0;i < GRADE_NUMBER;i++){ 1078 for(j=0;j < CLASS_NUMBER;j++){ 1079 // if(strcmp(stu_Score_information8[j].name,stu_Score_information_grade[i].name) == 0){ 1080 // stu_Score_information8[j].student_ID = stu_Score_information_grade[i].student_ID; 1081 // } 1082 if(stu_Score_information8[j].YuWen_Score == preYuwen[i]){ 1083 // stu[j].Yuwen_ranking = i; 1084 if(preYuwen[i] == YuwenFlagValue){ 1085 stu_Score_information8[j].Yuwen_ranking = YuwenFlag; 1086 // stu2[j].Yuwen_ranking = YuwenFlag; 1087 }else{ 1088 stu_Score_information8[j].Yuwen_ranking = q1; 1089 // stu2[j].Yuwen_ranking = q; 1090 q1++; 1091 } 1092 1093 if(preYuwen[i] != YuwenFlagValue){ 1094 YuwenFlagValue = preYuwen[i]; 1095 YuwenFlag = stu_Score_information8[j].Yuwen_ranking; 1096 } 1097 } 1098 } 1099 } 1100 for(i=0;i < GRADE_NUMBER;i++){ 1101 for(j=0;j < CLASS_NUMBER;j++){ 1102 if(stu_Score_information8[j].Math_Score == preMath[i]){ 1103 // stu[j].Yuwen_ranking = i; 1104 if(preMath[i] == MathFlagValue){ 1105 stu_Score_information8[j].Math_ranking = MathFlag; 1106 // stu2[j].Yuwen_ranking = YuwenFlag; 1107 }else{ 1108 stu_Score_information8[j].Math_ranking = q2; 1109 // stu2[j].Yuwen_ranking = q; 1110 q2++; 1111 } 1112 1113 if(preMath[i] != MathFlagValue){ 1114 MathFlagValue = preMath[i]; 1115 MathFlag = stu_Score_information8[j].Math_ranking; 1116 } 1117 } 1118 } 1119 } 1120 1121 for(i=0;i < GRADE_NUMBER;i++){ 1122 for(j=0;j < CLASS_NUMBER;j++){ 1123 if(stu_Score_information8[j].English_Score == preEnglish[i]){ 1124 // stu[j].Yuwen_ranking = i; 1125 if(preEnglish[i] == EnglishFlagValue){ 1126 stu_Score_information8[j].English_ranking = EnglishFlag; 1127 // stu2[j].Yuwen_ranking = YuwenFlag; 1128 }else{ 1129 stu_Score_information8[j].English_ranking = q3; 1130 // stu2[j].Yuwen_ranking = q; 1131 q3++; 1132 } 1133 1134 if(preEnglish[i] != EnglishFlagValue){ 1135 EnglishFlagValue = preEnglish[i]; 1136 EnglishFlag = stu_Score_information8[j].English_ranking; 1137 } 1138 } 1139 } 1140 } 1141 1142 printf("姓名\t班级\t学号\t语文\t语文年级排名\t数学\t数学年级排名\t英语\t英语年级排名\t总分\t班级排名\n"); 1143 for(m = 0;m < CLASS_NUMBER;m++){ 1144 printf("%s\t11808班\t%3d\t%1.3f\t%4d\t\t%1.3f\t%4d\t\t%1.3f\t%4d\t\t%1.3f\t%3d\r\n", 1145 stu_Score_information8[m].name,stu_Score_information8[m].student_ID, 1146 stu_Score_information8[m].YuWen_Score,stu_Score_information8[m].Yuwen_ranking, 1147 stu_Score_information8[m].Math_Score,stu_Score_information8[m].Math_ranking, 1148 stu_Score_information8[m].English_Score,stu_Score_information8[m].English_ranking, 1149 stu_Score_information8[m].all_score,stu_Score_information8[m].allscore_Grade_ranking); 1150 1151 } 1152 break; 1153 case 9: 1154 system("cls"); 1155 printf(" **************11809班成绩名单********************\n"); 1156 all_add_score(stu_Score_information9,preclass9_allscore,CLASS_NUMBER); 1157 Sort(stu_Score_information9,CLASS_NUMBER); 1158 for(i=0;i < GRADE_NUMBER;i++){ 1159 for(j=0;j < CLASS_NUMBER;j++){ 1160 // if(strcmp(stu_Score_information9[j].name,stu_Score_information_grade[i].name) == 0){ 1161 // stu_Score_information9[j].student_ID = stu_Score_information_grade[i].student_ID; 1162 // } 1163 if(stu_Score_information9[j].YuWen_Score == preYuwen[i]){ 1164 // stu[j].Yuwen_ranking = i; 1165 if(preYuwen[i] == YuwenFlagValue){ 1166 stu_Score_information9[j].Yuwen_ranking = YuwenFlag; 1167 // stu2[j].Yuwen_ranking = YuwenFlag; 1168 }else{ 1169 stu_Score_information9[j].Yuwen_ranking = q1; 1170 // stu2[j].Yuwen_ranking = q; 1171 q1++; 1172 } 1173 1174 if(preYuwen[i] != YuwenFlagValue){ 1175 YuwenFlagValue = preYuwen[i]; 1176 YuwenFlag = stu_Score_information9[j].Yuwen_ranking; 1177 } 1178 } 1179 } 1180 } 1181 for(i=0;i < GRADE_NUMBER;i++){ 1182 for(j=0;j < CLASS_NUMBER;j++){ 1183 if(stu_Score_information9[j].Math_Score == preMath[i]){ 1184 // stu[j].Yuwen_ranking = i; 1185 if(preMath[i] == MathFlagValue){ 1186 stu_Score_information9[j].Math_ranking = MathFlag; 1187 // stu2[j].Yuwen_ranking = YuwenFlag; 1188 }else{ 1189 stu_Score_information9[j].Math_ranking = q2; 1190 // stu2[j].Yuwen_ranking = q; 1191 q2++; 1192 } 1193 1194 if(preMath[i] != MathFlagValue){ 1195 MathFlagValue = preMath[i]; 1196 MathFlag = stu_Score_information9[j].Math_ranking; 1197 } 1198 } 1199 } 1200 } 1201 1202 for(i=0;i < GRADE_NUMBER;i++){ 1203 for(j=0;j < CLASS_NUMBER;j++){ 1204 if(stu_Score_information9[j].English_Score == preEnglish[i]){ 1205 // stu[j].Yuwen_ranking = i; 1206 if(preEnglish[i] == EnglishFlagValue){ 1207 stu_Score_information9[j].English_ranking = EnglishFlag; 1208 // stu2[j].Yuwen_ranking = YuwenFlag; 1209 }else{ 1210 stu_Score_information9[j].English_ranking = q3; 1211 // stu2[j].Yuwen_ranking = q; 1212 q3++; 1213 } 1214 1215 if(preEnglish[i] != EnglishFlagValue){ 1216 EnglishFlagValue = preEnglish[i]; 1217 EnglishFlag = stu_Score_information9[j].English_ranking; 1218 } 1219 } 1220 } 1221 } 1222 1223 printf("姓名\t班级\t学号\t语文\t语文年级排名\t数学\t数学年级排名\t英语\t英语年级排名\t总分\t班级排名\n"); 1224 for(m = 0;m < CLASS_NUMBER;m++){ 1225 printf("%s\t11809班\t%3d\t%1.3f\t%4d\t\t%1.3f\t%4d\t\t%1.3f\t%4d\t\t%1.3f\t%3d\r\n", 1226 stu_Score_information9[m].name,stu_Score_information9[m].student_ID, 1227 stu_Score_information9[m].YuWen_Score,stu_Score_information9[m].Yuwen_ranking, 1228 stu_Score_information9[m].Math_Score,stu_Score_information9[m].Math_ranking, 1229 stu_Score_information9[m].English_Score,stu_Score_information9[m].English_ranking, 1230 stu_Score_information9[m].all_score,stu_Score_information9[m].allscore_Grade_ranking); 1231 1232 } 1233 break; 1234 case 10: 1235 system("cls"); 1236 printf(" **************11810班成绩名单********************\n"); 1237 all_add_score(stu_Score_information10,preclass10_allscore,CLASS_NUMBER); 1238 Sort(stu_Score_information10,CLASS_NUMBER); 1239 for(i=0;i < GRADE_NUMBER;i++){ 1240 for(j=0;j < CLASS_NUMBER;j++){ 1241 // if(strcmp(stu_Score_information10[j].name,stu_Score_information_grade[i].name) == 0){ 1242 // stu_Score_information10[j].student_ID = stu_Score_information_grade[i].student_ID; 1243 // } 1244 if(stu_Score_information10[j].YuWen_Score == preYuwen[i]){ 1245 // stu[j].Yuwen_ranking = i; 1246 if(preYuwen[i] == YuwenFlagValue){ 1247 stu_Score_information10[j].Yuwen_ranking = YuwenFlag; 1248 // stu2[j].Yuwen_ranking = YuwenFlag; 1249 }else{ 1250 stu_Score_information10[j].Yuwen_ranking = q1; 1251 // stu2[j].Yuwen_ranking = q; 1252 q1++; 1253 } 1254 1255 if(preYuwen[i] != YuwenFlagValue){ 1256 YuwenFlagValue = preYuwen[i]; 1257 YuwenFlag = stu_Score_information10[j].Yuwen_ranking; 1258 } 1259 } 1260 } 1261 } 1262 for(i=0;i < GRADE_NUMBER;i++){ 1263 for(j=0;j < CLASS_NUMBER;j++){ 1264 if(stu_Score_information10[j].Math_Score == preMath[i]){ 1265 // stu[j].Yuwen_ranking = i; 1266 if(preMath[i] == MathFlagValue){ 1267 stu_Score_information10[j].Math_ranking = MathFlag; 1268 // stu2[j].Yuwen_ranking = YuwenFlag; 1269 }else{ 1270 stu_Score_information10[j].Math_ranking = q2; 1271 // stu2[j].Yuwen_ranking = q; 1272 q2++; 1273 } 1274 1275 if(preMath[i] != MathFlagValue){ 1276 MathFlagValue = preMath[i]; 1277 MathFlag = stu_Score_information10[j].Math_ranking; 1278 } 1279 } 1280 } 1281 } 1282 1283 for(i=0;i < GRADE_NUMBER;i++){ 1284 for(j=0;j < CLASS_NUMBER;j++){ 1285 if(stu_Score_information10[j].English_Score == preEnglish[i]){ 1286 // stu[j].Yuwen_ranking = i; 1287 if(preEnglish[i] == EnglishFlagValue){ 1288 stu_Score_information10[j].English_ranking = EnglishFlag; 1289 // stu2[j].Yuwen_ranking = YuwenFlag; 1290 }else{ 1291 stu_Score_information10[j].English_ranking = q3; 1292 // stu2[j].Yuwen_ranking = q; 1293 q3++; 1294 } 1295 1296 if(preEnglish[i] != EnglishFlagValue){ 1297 EnglishFlagValue = preEnglish[i]; 1298 EnglishFlag = stu_Score_information10[j].English_ranking; 1299 } 1300 } 1301 } 1302 } 1303 1304 printf("姓名\t班级\t学号\t语文\t语文年级排名\t数学\t数学年级排名\t英语\t英语年级排名\t总分\t班级排名\n"); 1305 for(m = 0;m < CLASS_NUMBER;m++){ 1306 printf("%s\t11810班\t%3d\t%1.3f\t%4d\t\t%1.3f\t%4d\t\t%1.3f\t%4d\t\t%1.3f\t%3d\r\n", 1307 stu_Score_information10[m].name,stu_Score_information10[m].student_ID, 1308 stu_Score_information10[m].YuWen_Score,stu_Score_information10[m].Yuwen_ranking, 1309 stu_Score_information10[m].Math_Score,stu_Score_information10[m].Math_ranking, 1310 stu_Score_information10[m].English_Score,stu_Score_information10[m].English_ranking, 1311 stu_Score_information10[m].all_score,stu_Score_information10[m].allscore_Grade_ranking); 1312 1313 } 1314 break; 1315 case 11: 1316 system("cls"); 1317 1318 interface(); 1319 1320 flag3 = 0; 1321 break; 1322 } 1323 } 1324 break; 1325 case 4: 1326 system("cls"); 1327 save(); 1328 interface(); 1329 printf(" 保存完成!\n"); 1330 break; 1331 case 5: 1332 system("cls"); 1333 read(); 1334 interface(); 1335 break; 1336 case 6: 1337 system("cls"); 1338 help(); 1339 break; 1340 case 7: 1341 system("cls"); 1342 Exit(); 1343 1344 } 1345 } 1346 } 1347 1348 void save(void){ 1349 int i; 1350 FILE *fp; 1351 fp = fopen("stugrade.txt","w"); 1352 // fprintf(fp,"姓名\t学号\t语文\t语文年级排名\t数学\t数学年级排名\t英语\t英语年级排名\t总分\t年级排名\n"); 1353 for(i = 0; i < GRADE_NUMBER;i++){ 1354 fprintf(fp,"%s %d %f %d %f %d %f %d %f %d\n", 1355 stu_Score_information_grade[i].name,stu_Score_information_grade[i].student_ID, 1356 stu_Score_information_grade[i].YuWen_Score,stu_Score_information_grade[i].Yuwen_ranking, 1357 stu_Score_information_grade[i].Math_Score,stu_Score_information_grade[i].Math_ranking, 1358 stu_Score_information_grade[i].English_Score,stu_Score_information_grade[i].English_ranking, 1359 stu_Score_information_grade[i].all_score,stu_Score_information_grade[i].allscore_Grade_ranking); 1360 } 1361 fclose(fp); 1362 1363 FILE *fp1; 1364 fp1 = fopen("stuclass1.txt","w"); 1365 // fprintf(fp1,"姓名\t班级\t学号\t语文\t语文年级排名\t数学\t数学年级排名\t英语\t英语年级排名\t总分\t班级排名\n"); 1366 for(i = 0; i < CLASS_NUMBER;i++){ 1367 fprintf(fp1,"%s %d %f %d %f %d %f %d %f %d\n", 1368 stu_Score_information1[i].name,stu_Score_information1[i].student_ID, 1369 stu_Score_information1[i].YuWen_Score,stu_Score_information1[i].Yuwen_ranking, 1370 stu_Score_information1[i].Math_Score,stu_Score_information1[i].Math_ranking, 1371 stu_Score_information1[i].English_Score,stu_Score_information1[i].English_ranking, 1372 stu_Score_information1[i].all_score,stu_Score_information1[i].allscore_Grade_ranking); 1373 } 1374 fclose(fp1); 1375 1376 FILE *fp2; 1377 fp2 = fopen("stuclass2.txt","w"); 1378 // fprintf(fp2,"姓名\t班级\t学号\t语文\t语文年级排名\t数学\t数学年级排名\t英语\t英语年级排名\t总分\t班级排名\n"); 1379 for(i = 0; i < CLASS_NUMBER;i++){ 1380 fprintf(fp2,"%s %d %f %d %f %d %f %d %f %d\n", 1381 stu_Score_information2[i].name,stu_Score_information2[i].student_ID, 1382 stu_Score_information2[i].YuWen_Score,stu_Score_information2[i].Yuwen_ranking, 1383 stu_Score_information2[i].Math_Score,stu_Score_information2[i].Math_ranking, 1384 stu_Score_information2[i].English_Score,stu_Score_information2[i].English_ranking, 1385 stu_Score_information2[i].all_score,stu_Score_information2[i].allscore_Grade_ranking); 1386 } 1387 fclose(fp2); 1388 1389 FILE *fp3; 1390 fp3 = fopen("stuclass3.txt","w"); 1391 // fprintf(fp3,"姓名\t班级\t学号\t语文\t语文年级排名\t数学\t数学年级排名\t英语\t英语年级排名\t总分\t班级排名\n"); 1392 for(i = 0; i < CLASS_NUMBER;i++){ 1393 fprintf(fp3,"%s %d %f %d %f %d %f %d %f %d\n", 1394 stu_Score_information3[i].name,stu_Score_information3[i].student_ID, 1395 stu_Score_information3[i].YuWen_Score,stu_Score_information3[i].Yuwen_ranking, 1396 stu_Score_information3[i].Math_Score,stu_Score_information3[i].Math_ranking, 1397 stu_Score_information3[i].English_Score,stu_Score_information3[i].English_ranking, 1398 stu_Score_information3[i].all_score,stu_Score_information3[i].allscore_Grade_ranking); 1399 } 1400 fclose(fp3); 1401 1402 FILE *fp4; 1403 fp4 = fopen("stuclass4.txt","w"); 1404 // fprintf(fp4,"姓名\t班级\t学号\t语文\t语文年级排名\t数学\t数学年级排名\t英语\t英语年级排名\t总分\t班级排名\n"); 1405 for(i = 0; i < CLASS_NUMBER;i++){ 1406 fprintf(fp4,"%s %d %f %d %f %d %f %d %f %d\n", 1407 stu_Score_information4[i].name,stu_Score_information4[i].student_ID, 1408 stu_Score_information4[i].YuWen_Score,stu_Score_information4[i].Yuwen_ranking, 1409 stu_Score_information4[i].Math_Score,stu_Score_information4[i].Math_ranking, 1410 stu_Score_information4[i].English_Score,stu_Score_information4[i].English_ranking, 1411 stu_Score_information4[i].all_score,stu_Score_information4[i].allscore_Grade_ranking); 1412 } 1413 fclose(fp4); 1414 1415 FILE *fp5; 1416 fp5 = fopen("stuclass5.txt","w"); 1417 // fprintf(fp5,"姓名\t班级\t学号\t语文\t语文年级排名\t数学\t数学年级排名\t英语\t英语年级排名\t总分\t班级排名\n"); 1418 for(i = 0; i < CLASS_NUMBER;i++){ 1419 fprintf(fp5,"%s %d %f %d %f %d %f %d %f %d\n", 1420 stu_Score_information5[i].name,stu_Score_information5[i].student_ID, 1421 stu_Score_information5[i].YuWen_Score,stu_Score_information5[i].Yuwen_ranking, 1422 stu_Score_information5[i].Math_Score,stu_Score_information5[i].Math_ranking, 1423 stu_Score_information5[i].English_Score,stu_Score_information5[i].English_ranking, 1424 stu_Score_information5[i].all_score,stu_Score_information5[i].allscore_Grade_ranking); 1425 } 1426 fclose(fp5); 1427 1428 FILE *fp6; 1429 fp6 = fopen("stuclass6.txt","w"); 1430 // fprintf(fp6,"姓名\t班级\t学号\t语文\t语文年级排名\t数学\t数学年级排名\t英语\t英语年级排名\t总分\t班级排名\n"); 1431 for(i = 0; i < CLASS_NUMBER;i++){ 1432 fprintf(fp6,"%s %d %f %d %f %d %f %d %f %d\n", 1433 stu_Score_information6[i].name,stu_Score_information6[i].student_ID, 1434 stu_Score_information6[i].YuWen_Score,stu_Score_information6[i].Yuwen_ranking, 1435 stu_Score_information6[i].Math_Score,stu_Score_information6[i].Math_ranking, 1436 stu_Score_information6[i].English_Score,stu_Score_information6[i].English_ranking, 1437 stu_Score_information6[i].all_score,stu_Score_information6[i].allscore_Grade_ranking); 1438 } 1439 fclose(fp6); 1440 1441 1442 FILE *fp7; 1443 fp7 = fopen("stuclass7.txt","w"); 1444 // fprintf(fp7,"姓名\t班级\t学号\t语文\t语文年级排名\t数学\t数学年级排名\t英语\t英语年级排名\t总分\t班级排名\n"); 1445 for(i = 0; i < CLASS_NUMBER;i++){ 1446 fprintf(fp7,"%s %d %f %d %f %d %f %d %f %d\n", 1447 stu_Score_information7[i].name,stu_Score_information7[i].student_ID, 1448 stu_Score_information7[i].YuWen_Score,stu_Score_information7[i].Yuwen_ranking, 1449 stu_Score_information7[i].Math_Score,stu_Score_information7[i].Math_ranking, 1450 stu_Score_information7[i].English_Score,stu_Score_information7[i].English_ranking, 1451 stu_Score_information7[i].all_score,stu_Score_information7[i].allscore_Grade_ranking); 1452 } 1453 fclose(fp7); 1454 1455 FILE *fp8; 1456 fp8 = fopen("stuclass8.txt","w"); 1457 // fprintf(fp8,"姓名\t班级\t学号\t语文\t语文年级排名\t数学\t数学年级排名\t英语\t英语年级排名\t总分\t班级排名\n"); 1458 for(i = 0; i < CLASS_NUMBER;i++){ 1459 fprintf(fp8,"%s %d %f %d %f %d %f %d %f %d\n", 1460 stu_Score_information8[i].name,stu_Score_information8[i].student_ID, 1461 stu_Score_information8[i].YuWen_Score,stu_Score_information8[i].Yuwen_ranking, 1462 stu_Score_information8[i].Math_Score,stu_Score_information8[i].Math_ranking, 1463 stu_Score_information8[i].English_Score,stu_Score_information8[i].English_ranking, 1464 stu_Score_information8[i].all_score,stu_Score_information8[i].allscore_Grade_ranking); 1465 } 1466 fclose(fp8); 1467 1468 FILE *fp9; 1469 fp9 = fopen("stuclass9.txt","w"); 1470 // fprintf(fp9,"姓名\t班级\t学号\t语文\t语文年级排名\t数学\t数学年级排名\t英语\t英语年级排名\t总分\t班级排名\n"); 1471 for(i = 0; i < CLASS_NUMBER;i++){ 1472 fprintf(fp9,"%s %d %f %d %f %d %f %d %f %d\n", 1473 stu_Score_information9[i].name,stu_Score_information9[i].student_ID, 1474 stu_Score_information9[i].YuWen_Score,stu_Score_information9[i].Yuwen_ranking, 1475 stu_Score_information9[i].Math_Score,stu_Score_information9[i].Math_ranking, 1476 stu_Score_information9[i].English_Score,stu_Score_information9[i].English_ranking, 1477 stu_Score_information9[i].all_score,stu_Score_information9[i].allscore_Grade_ranking); 1478 } 1479 fclose(fp9); 1480 1481 FILE *fp10; 1482 fp10 = fopen("stuclass10.txt","w"); 1483 // fprintf(fp10,"姓名\t班级\t学号\t语文\t语文年级排名\t数学\t数学年级排名\t英语\t英语年级排名\t总分\t班级排名\n"); 1484 for(i = 0; i < CLASS_NUMBER;i++){ 1485 fprintf(fp10,"%s %d %f %d %f %d %f %d %f %d\n", 1486 stu_Score_information10[i].name,stu_Score_information10[i].student_ID, 1487 stu_Score_information10[i].YuWen_Score,stu_Score_information10[i].Yuwen_ranking, 1488 stu_Score_information10[i].Math_Score,stu_Score_information10[i].Math_ranking, 1489 stu_Score_information10[i].English_Score,stu_Score_information10[i].English_ranking, 1490 stu_Score_information10[i].all_score,stu_Score_information10[i].allscore_Grade_ranking); 1491 } 1492 fclose(fp10); 1493 1494 } 1495 1496 //读取磁盘信息 1497 void read(void){ 1498 char *a[10]; 1499 int b,d,f,h,k; 1500 float c,e,g,j; 1501 int i = 0; 1502 1503 char *p = "stugrade.txt"; 1504 FILE *fp; 1505 fp=fopen("stugrade.txt","r+");//以读写的方式打开文件,若没有文件,则创建一个 1506 if ((fp=fopen("stugrade.txt","r+"))==NULL)//如果打开失败,则进入if语句 1507 { 1508 printf("Open file %s error! Strike any key to exit!",p); 1509 system("pause"); 1510 exit(0); 1511 } 1512 1513 while(fscanf(fp,"%s%d%f%d%f%d%f%d%f%d",a,&b,&c,&d,&e,&f,&g,&h,&j,&k)==10) 1514 { 1515 //printf("%s\t%3d\t%1.3f\t%4d\t\t%1.3f\t%4d\t\t%1.3f\t%4d\t\t%1.3f\t%3d\r\n",a,b,c,d,e,f,g,h,j,k); 1516 strcpy(stu_Score_information_grade[i].name,a); 1517 stu_Score_information_grade[i].student_ID = b; 1518 stu_Score_information_grade[i].YuWen_Score = c; 1519 stu_Score_information_grade[i].Yuwen_ranking = d; 1520 stu_Score_information_grade[i].Math_Score = e; 1521 stu_Score_information_grade[i].Math_ranking = f; 1522 stu_Score_information_grade[i].English_Score = g; 1523 stu_Score_information_grade[i].English_ranking = h; 1524 stu_Score_information_grade[i].all_score = j; 1525 stu_Score_information_grade[i].allscore_Grade_ranking = k; 1526 i=i+1; 1527 } 1528 i = 0; 1529 fclose(fp); 1530 1531 char *p1 = "stuclass1.txt"; 1532 FILE *fp1; 1533 fp1=fopen("stuclass1.txt","r+");//以读写的方式打开文件,若没有文件,则创建一个 1534 if ((fp1=fopen("stuclass1.txt","r+"))==NULL)//如果打开失败,则进入if语句 1535 { 1536 printf("Open file %s error! Strike any key to exit!",p1); 1537 system("pause"); 1538 exit(0); 1539 } 1540 1541 while(fscanf(fp1,"%s%d%f%d%f%d%f%d%f%d",a,&b,&c,&d,&e,&f,&g,&h,&j,&k)==10) 1542 { 1543 //printf("%s\t%3d\t%1.3f\t%4d\t\t%1.3f\t%4d\t\t%1.3f\t%4d\t\t%1.3f\t%3d\r\n",a,b,c,d,e,f,g,h,j,k); 1544 strcpy(stu_Score_information1[i].name,a); 1545 stu_Score_information1[i].student_ID = b; 1546 stu_Score_information1[i].YuWen_Score = c; 1547 stu_Score_information1[i].Yuwen_ranking = d; 1548 stu_Score_information1[i].Math_Score = e; 1549 stu_Score_information1[i].Math_ranking = f; 1550 stu_Score_information1[i].English_Score = g; 1551 stu_Score_information1[i].English_ranking = h; 1552 stu_Score_information1[i].all_score = j; 1553 stu_Score_information1[i].allscore_Grade_ranking = k; 1554 i=i+1; 1555 } 1556 i = 0; 1557 fclose(fp1); 1558 1559 char *p2 = "stuclass2.txt"; 1560 FILE *fp2; 1561 fp2=fopen("stuclass2.txt","r+");//以读写的方式打开文件,若没有文件,则创建一个 1562 if ((fp2=fopen("stuclass2.txt","r+"))==NULL)//如果打开失败,则进入if语句 1563 { 1564 printf("Open file %s error! Strike any key to exit!",p2); 1565 system("pause"); 1566 exit(0); 1567 } 1568 1569 while(fscanf(fp2,"%s%d%f%d%f%d%f%d%f%d",a,&b,&c,&d,&e,&f,&g,&h,&j,&k)==10) 1570 { 1571 //printf("%s\t%3d\t%1.3f\t%4d\t\t%1.3f\t%4d\t\t%1.3f\t%4d\t\t%1.3f\t%3d\r\n",a,b,c,d,e,f,g,h,j,k); 1572 strcpy(stu_Score_information2[i].name,a); 1573 stu_Score_information2[i].student_ID = b; 1574 stu_Score_information2[i].YuWen_Score = c; 1575 stu_Score_information2[i].Yuwen_ranking = d; 1576 stu_Score_information2[i].Math_Score = e; 1577 stu_Score_information2[i].Math_ranking = f; 1578 stu_Score_information2[i].English_Score = g; 1579 stu_Score_information2[i].English_ranking = h; 1580 stu_Score_information2[i].all_score = j; 1581 stu_Score_information2[i].allscore_Grade_ranking = k; 1582 i=i+1; 1583 } 1584 i = 0; 1585 fclose(fp2); 1586 1587 char *p3 = "stuclass3.txt"; 1588 FILE *fp3; 1589 fp3=fopen("stuclass3.txt","r+");//以读写的方式打开文件,若没有文件,则创建一个 1590 if ((fp3=fopen("stuclass3.txt","r+"))==NULL)//如果打开失败,则进入if语句 1591 { 1592 printf("Open file %s error! Strike any key to exit!",p3); 1593 system("pause"); 1594 exit(0); 1595 } 1596 1597 while(fscanf(fp3,"%s%d%f%d%f%d%f%d%f%d",a,&b,&c,&d,&e,&f,&g,&h,&j,&k)==10) 1598 { 1599 //printf("%s\t%3d\t%1.3f\t%4d\t\t%1.3f\t%4d\t\t%1.3f\t%4d\t\t%1.3f\t%3d\r\n",a,b,c,d,e,f,g,h,j,k); 1600 strcpy(stu_Score_information3[i].name,a); 1601 stu_Score_information3[i].student_ID = b; 1602 stu_Score_information3[i].YuWen_Score = c; 1603 stu_Score_information3[i].Yuwen_ranking = d; 1604 stu_Score_information3[i].Math_Score = e; 1605 stu_Score_information3[i].Math_ranking = f; 1606 stu_Score_information3[i].English_Score = g; 1607 stu_Score_information3[i].English_ranking = h; 1608 stu_Score_information3[i].all_score = j; 1609 stu_Score_information3[i].allscore_Grade_ranking = k; 1610 i=i+1; 1611 } 1612 i = 0; 1613 fclose(fp3); 1614 1615 char *p4 = "stuclass4.txt"; 1616 FILE *fp4; 1617 fp4=fopen("stuclass4.txt","r+");//以读写的方式打开文件,若没有文件,则创建一个 1618 if ((fp4=fopen("stuclass4.txt","r+"))==NULL)//如果打开失败,则进入if语句 1619 { 1620 printf("Open file %s error! Strike any key to exit!",p4); 1621 system("pause"); 1622 exit(0); 1623 } 1624 1625 while(fscanf(fp4,"%s%d%f%d%f%d%f%d%f%d",a,&b,&c,&d,&e,&f,&g,&h,&j,&k)==10) 1626 { 1627 //printf("%s\t%3d\t%1.3f\t%4d\t\t%1.3f\t%4d\t\t%1.3f\t%4d\t\t%1.3f\t%3d\r\n",a,b,c,d,e,f,g,h,j,k); 1628 strcpy(stu_Score_information4[i].name,a); 1629 stu_Score_information4[i].student_ID = b; 1630 stu_Score_information4[i].YuWen_Score = c; 1631 stu_Score_information4[i].Yuwen_ranking = d; 1632 stu_Score_information4[i].Math_Score = e; 1633 stu_Score_information4[i].Math_ranking = f; 1634 stu_Score_information4[i].English_Score = g; 1635 stu_Score_information4[i].English_ranking = h; 1636 stu_Score_information4[i].all_score = j; 1637 stu_Score_information4[i].allscore_Grade_ranking = k; 1638 i=i+1; 1639 } 1640 i = 0; 1641 fclose(fp4); 1642 1643 1644 char *p5 = "stuclass5.txt"; 1645 FILE *fp5; 1646 fp5=fopen("stuclass5.txt","r+");//以读写的方式打开文件,若没有文件,则创建一个 1647 if ((fp5=fopen("stuclass5.txt","r+"))==NULL)//如果打开失败,则进入if语句 1648 { 1649 printf("Open file %s error! Strike any key to exit!",p5); 1650 system("pause"); 1651 exit(0); 1652 } 1653 1654 while(fscanf(fp5,"%s%d%f%d%f%d%f%d%f%d",a,&b,&c,&d,&e,&f,&g,&h,&j,&k)==10) 1655 { 1656 //printf("%s\t%3d\t%1.3f\t%4d\t\t%1.3f\t%4d\t\t%1.3f\t%4d\t\t%1.3f\t%3d\r\n",a,b,c,d,e,f,g,h,j,k); 1657 strcpy(stu_Score_information5[i].name,a); 1658 stu_Score_information5[i].student_ID = b; 1659 stu_Score_information5[i].YuWen_Score = c; 1660 stu_Score_information5[i].Yuwen_ranking = d; 1661 stu_Score_information5[i].Math_Score = e; 1662 stu_Score_information5[i].Math_ranking = f; 1663 stu_Score_information5[i].English_Score = g; 1664 stu_Score_information5[i].English_ranking = h; 1665 stu_Score_information5[i].all_score = j; 1666 stu_Score_information5[i].allscore_Grade_ranking = k; 1667 i=i+1; 1668 } 1669 i = 0; 1670 fclose(fp5); 1671 1672 char *p6 = "stuclass6.txt"; 1673 FILE *fp6; 1674 fp6=fopen("stuclass6.txt","r+");//以读写的方式打开文件,若没有文件,则创建一个 1675 if ((fp6=fopen("stuclass6.txt","r+"))==NULL)//如果打开失败,则进入if语句 1676 { 1677 printf("Open file %s error! Strike any key to exit!",p6); 1678 system("pause"); 1679 exit(0); 1680 } 1681 1682 while(fscanf(fp6,"%s%d%f%d%f%d%f%d%f%d",a,&b,&c,&d,&e,&f,&g,&h,&j,&k)==10) 1683 { 1684 //printf("%s\t%3d\t%1.3f\t%4d\t\t%1.3f\t%4d\t\t%1.3f\t%4d\t\t%1.3f\t%3d\r\n",a,b,c,d,e,f,g,h,j,k); 1685 strcpy(stu_Score_information6[i].name,a); 1686 stu_Score_information6[i].student_ID = b; 1687 stu_Score_information6[i].YuWen_Score = c; 1688 stu_Score_information6[i].Yuwen_ranking = d; 1689 stu_Score_information6[i].Math_Score = e; 1690 stu_Score_information6[i].Math_ranking = f; 1691 stu_Score_information6[i].English_Score = g; 1692 stu_Score_information6[i].English_ranking = h; 1693 stu_Score_information6[i].all_score = j; 1694 stu_Score_information6[i].allscore_Grade_ranking = k; 1695 i=i+1; 1696 } 1697 i = 0; 1698 fclose(fp6); 1699 1700 char *p7 = "stuclass7.txt"; 1701 FILE *fp7; 1702 fp7=fopen("stuclass7.txt","r+");//以读写的方式打开文件,若没有文件,则创建一个 1703 if ((fp7=fopen("stuclass7.txt","r+"))==NULL)//如果打开失败,则进入if语句 1704 { 1705 printf("Open file %s error! Strike any key to exit!",p7); 1706 system("pause"); 1707 exit(0); 1708 } 1709 1710 while(fscanf(fp7,"%s%d%f%d%f%d%f%d%f%d",a,&b,&c,&d,&e,&f,&g,&h,&j,&k)==10) 1711 { 1712 //printf("%s\t%3d\t%1.3f\t%4d\t\t%1.3f\t%4d\t\t%1.3f\t%4d\t\t%1.3f\t%3d\r\n",a,b,c,d,e,f,g,h,j,k); 1713 strcpy(stu_Score_information7[i].name,a); 1714 stu_Score_information7[i].student_ID = b; 1715 stu_Score_information7[i].YuWen_Score = c; 1716 stu_Score_information7[i].Yuwen_ranking = d; 1717 stu_Score_information7[i].Math_Score = e; 1718 stu_Score_information7[i].Math_ranking = f; 1719 stu_Score_information7[i].English_Score = g; 1720 stu_Score_information7[i].English_ranking = h; 1721 stu_Score_information7[i].all_score = j; 1722 stu_Score_information7[i].allscore_Grade_ranking = k; 1723 i=i+1; 1724 } 1725 i = 0; 1726 fclose(fp7); 1727 1728 char *p8 = "stuclass8.txt"; 1729 FILE *fp8; 1730 fp8=fopen("stuclass8.txt","r+");//以读写的方式打开文件,若没有文件,则创建一个 1731 if ((fp8=fopen("stuclass8.txt","r+"))==NULL)//如果打开失败,则进入if语句 1732 { 1733 printf("Open file %s error! Strike any key to exit!",p8); 1734 system("pause"); 1735 exit(0); 1736 } 1737 1738 while(fscanf(fp8,"%s%d%f%d%f%d%f%d%f%d",a,&b,&c,&d,&e,&f,&g,&h,&j,&k)==10) 1739 { 1740 //printf("%s\t%3d\t%1.3f\t%4d\t\t%1.3f\t%4d\t\t%1.3f\t%4d\t\t%1.3f\t%3d\r\n",a,b,c,d,e,f,g,h,j,k); 1741 strcpy(stu_Score_information8[i].name,a); 1742 stu_Score_information8[i].student_ID = b; 1743 stu_Score_information8[i].YuWen_Score = c; 1744 stu_Score_information8[i].Yuwen_ranking = d; 1745 stu_Score_information8[i].Math_Score = e; 1746 stu_Score_information8[i].Math_ranking = f; 1747 stu_Score_information8[i].English_Score = g; 1748 stu_Score_information8[i].English_ranking = h; 1749 stu_Score_information8[i].all_score = j; 1750 stu_Score_information8[i].allscore_Grade_ranking = k; 1751 i=i+1; 1752 } 1753 i = 0; 1754 fclose(fp8); 1755 1756 char *p9 = "stuclass9.txt"; 1757 FILE *fp9; 1758 fp9=fopen("stuclass9.txt","r+");//以读写的方式打开文件,若没有文件,则创建一个 1759 if ((fp9=fopen("stuclass9.txt","r+"))==NULL)//如果打开失败,则进入if语句 1760 { 1761 printf("Open file %s error! Strike any key to exit!",p9); 1762 system("pause"); 1763 exit(0); 1764 } 1765 1766 while(fscanf(fp9,"%s%d%f%d%f%d%f%d%f%d",a,&b,&c,&d,&e,&f,&g,&h,&j,&k)==10) 1767 { 1768 //printf("%s\t%3d\t%1.3f\t%4d\t\t%1.3f\t%4d\t\t%1.3f\t%4d\t\t%1.3f\t%3d\r\n",a,b,c,d,e,f,g,h,j,k); 1769 strcpy(stu_Score_information9[i].name,a); 1770 stu_Score_information9[i].student_ID = b; 1771 stu_Score_information9[i].YuWen_Score = c; 1772 stu_Score_information9[i].Yuwen_ranking = d; 1773 stu_Score_information9[i].Math_Score = e; 1774 stu_Score_information9[i].Math_ranking = f; 1775 stu_Score_information9[i].English_Score = g; 1776 stu_Score_information9[i].English_ranking = h; 1777 stu_Score_information9[i].all_score = j; 1778 stu_Score_information9[i].allscore_Grade_ranking = k; 1779 i=i+1; 1780 } 1781 i = 0; 1782 fclose(fp9); 1783 1784 char *p10 = "stuclass10.txt"; 1785 FILE *fp10; 1786 fp10=fopen("stuclass10.txt","r+");//以读写的方式打开文件,若没有文件,则创建一个 1787 if ((fp10=fopen("stuclass10.txt","r+"))==NULL)//如果打开失败,则进入if语句 1788 { 1789 printf("Open file %s error! Strike any key to exit!",p10); 1790 system("pause"); 1791 exit(0); 1792 } 1793 1794 while(fscanf(fp10,"%s%d%f%d%f%d%f%d%f%d",a,&b,&c,&d,&e,&f,&g,&h,&j,&k)==10) 1795 { 1796 //printf("%s\t%3d\t%1.3f\t%4d\t\t%1.3f\t%4d\t\t%1.3f\t%4d\t\t%1.3f\t%3d\r\n",a,b,c,d,e,f,g,h,j,k); 1797 strcpy(stu_Score_information10[i].name,a); 1798 stu_Score_information10[i].student_ID = b; 1799 stu_Score_information10[i].YuWen_Score = c; 1800 stu_Score_information10[i].Yuwen_ranking = d; 1801 stu_Score_information10[i].Math_Score = e; 1802 stu_Score_information10[i].Math_ranking = f; 1803 stu_Score_information10[i].English_Score = g; 1804 stu_Score_information10[i].English_ranking = h; 1805 stu_Score_information10[i].all_score = j; 1806 stu_Score_information10[i].allscore_Grade_ranking = k; 1807 i=i+1; 1808 } 1809 i = 0; 1810 fclose(fp10); 1811 printf("读取完毕!\n"); 1812 } 1813 1814 //帮助 1815 void help(void){ 1816 printf(" ****************************************\n\n"); 1817 printf(" 1.输入对应的序号实现相应的功能。\n\n") ; 1818 printf(" 2.在使用保存功能前必须有某个可以改变数据功能先工作,如想要保存三班成绩信息,就必须先使用显示三班成绩功能\n\n"); 1819 printf(" ****************************************\n\n"); 1820 } 1821 1822 void Exit(void){ 1823 exit(0); 1824 }

浙公网安备 33010602011771号