diff --git a/task5.cpp b/task5.cpp new file mode 100644 index 0000000..ab43612 --- /dev/null +++ b/task5.cpp @@ -0,0 +1,189 @@ +#include +#include + +#define MARK 10 + +//定义结构体 +struct Student +{ + int ID;//学号 + int classes; + char name[8]; + float math_grade; + float physics_grade; + float English_grade; + float sum; +}; + +//对结构体中的从start同学到end同学排序 +void Sort(struct Student information[4],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++; + } + else + { + break; + } + } + + if(con)//有人是同班同学,在此内排序 + { + for(int m=i;m='0') + { + int num=0; + for(int i=0;i