#include #include #include #define MARK 200 #define MAX_NUMBER 100 int l=0;//记录结构体现有同学的个数 //定义结构体 struct Student { int ID;//学号 int classes; char name[8]; float math_grade; float physics_grade; float English_grade; float sum; }; struct Student information[MAX_NUMBER]; void Interation(void); int pow10(int M) { int num=1; for(int i=1;i<=M;i++) { num*=10; } return num; } //显示主界面 void Show_The_Main_interface(void) { for(int i=1;i<=30;i++) { printf(" "); } printf("1.input\n"); for(int i=1;i<=30;i++) { printf(" "); } printf("2.delete\n"); for(int i=1;i<=30;i++) { printf(" "); } printf("3.select\n"); for(int i=1;i<=30;i++) { printf(" "); } printf("4.order\n"); for(int i=1;i<=30;i++) { printf(" "); } printf("5.output\n"); for(int i=1;i<=30;i++) { printf(" "); } printf("6.quit\n"); printf("please input your option\n"); } //输入第i个同学的信息 void Input_information(struct Student information[MAX_NUMBER],int i) { l++; char remind_information[8]; scanf("%s%d",remind_information,&information[i].ID); scanf("%s%d",remind_information,&information[i].classes); scanf("%s%s",remind_information,&information[i].name); scanf("%s%f",remind_information,&information[i].math_grade); scanf("%s%f",remind_information,&information[i].physics_grade); scanf("%s%f",remind_information,&information[i].English_grade); //计算总分,便于之后的对总成绩的排序 information[i].sum=information[i].math_grade+\ information[i].physics_grade+information[i].English_grade; printf("continue? \n"); char ch[5];scanf("%s",ch); if(ch[0]=='y') { Input_information(information,i+1); } else { Interation(); } } //对结构体中的从start同学到end同学排序 void Sort(struct Student information[MAX_NUMBER],int start,int end) { //先班级 for(int i=start;i<=end;i++) { for(int j=start;j<=end-1;j++) { if(information[j].classes>information[j+1].classes) { struct Student tmp=information[j]; information[j]=information[j+1]; information[j+1]=tmp; } } } //同班同学再成绩 for(int i=start;i<=end;i++) { int con=0;//记录连续了几人 for(int j=1;j<=end-i;j++) { if(information[i].classes==information[i+j].classes) {con=j; } else { break; } } if(con)//有人是同班同学,在此内排序 { for(int m=i;m<=i+con;m++) { for(int n=i;n<=i+con-1;n++) { if(information[n].sum='0') { int num=0; for(int i=0;i1) { Delete_information(information); } else { printf("请至少保留一个学生信息\n"); Interation(); } } else { Interation(); } } void Select_information(struct Student information[MAX_NUMBER]) { //输入待查找同学的信息 int select_student; scanf("%d", &select_student); struct Student select_information[MAX_NUMBER];//存放所有找到的同学信息 int j=0; int sign=0;//标记同学是否在系统里面 for(int i=0;i=3) { Sort(information,0,l-1); output(information,0,l-1); } else { printf("学生人数小于3,请输入学生信息后再来排序\n"); } Interation(); } else if(choice==5) { output(information,0,l-1); Interation(); } else if(choice==6) { } } int main() { Interation(); }