int main() { int i,choice,score,num;// 交互式查询 char query[20]; int num_students = read_student_info(students); printf("学生成绩表:\n"); display_all_students(students, num_students); while (1) { printf("\t\t\t\t¥¥**-------- 学生成绩管理系统-------**¥¥\n\n\n\n"); //菜单 printf("\t\t\t\t¥¥**1. 增加学生记录*******************¥¥ \n\n"); printf("\t\t\t\t¥¥**2. 将信息进行排序*****************¥¥ \n\n"); printf("\t\t\t\t¥¥**3. 查询学生成绩*******************¥¥ \n\n"); printf("\t\t\t\t¥¥**4. 查询各科平均分*****************¥¥ \n\n"); printf("\t\t\t\t¥¥**5. 退出***************************¥¥ \n\n\n"); printf("请选择(1-5):"); scanf("%d", &i); if (i == 5) { break; } else { switch (i) { case 1: addStudent(); num_students = read_student_info(students); break;
时间: 2023-07-05 13:26:05 浏览: 52
case 2: printf("请选择排序方式:1.按学号排序 2.按总分排序\n"); scanf("%d", &choice); if (choice == 1) { sort_by_id(students, num_students); } else if (choice == 2) { sort_by_total_score(students, num_students); } else { printf("请选择正确的选项!\n"); } break; case 3: printf("请输入要查询学生的姓名:"); scanf("%s", query); num = search_by_name(students, num_students, query); if (num == -1) { printf("查无此人!\n"); } else { display_one_student(students[num]); } break; case 4: display_average_score(students, num_students); break; default: printf("请选择正确的选项!\n"); break; } } } return 0; }
这是一个学生成绩管理系统的代码,你能解释一下它的运行逻辑吗?
阅读全文