diff --git a/6.c b/6.c new file mode 100644 index 0000000..68459b1 --- /dev/null +++ b/6.c @@ -0,0 +1,63 @@ +#include +#include +#define N 3 + +struct stu_info +{ + char num[20]; + int cls,flag; + char name[20]; + float math,physics,english; +}; + +struct stu_info stu[N]={{"10001",11,0,"Zhang",99.5,88.5,89.5}, + {"10002",12,0,"Yang",77.9,56.5,87.5}, + {"10003",11,0,"Liang",92.5,99.0,60.5}}; + +void sort(struct stu_info *stu,int n) +{ + int i,j; + struct stu_info tmp; + for(i=0;icls>(stu+j+1)->cls)||((stu+j)->cls==(stu+j+1)->cls)&&((stu+j)->num>(stu+j+1)->num)) + { + tmp = *(stu+j); + *(stu+j) = *(stu+j+1); + *(stu+j+1) = tmp; + } + } + } + return; +} + +int main() +{ + struct stu_info mod; + scanf("%s",&mod.num); + scanf("%d",&mod.cls); + scanf("%s",&mod.name); + scanf("%f",&mod.math); + scanf("%f",&mod.physics); + scanf("%f",&mod.english); + int i; + for(i=0;i