diff --git a/program 4.c b/program 4.c new file mode 100644 index 0000000..a389b89 --- /dev/null +++ b/program 4.c @@ -0,0 +1,55 @@ +#include +struct stu +{ + int num,c,x; + float m,p,e,s; +}; + +struct stu stu[4]={{10001,11,0,99.5,88.5,89.5,277.5}, + {10002,12,0,77.9,56.5,87.5,221.9}, + {10003,11,0,92.5,99.0,60.5,252},{}}; + +void min(struct stu *stu,int n) +{ + int i,j; + struct stu t; + for(i=0;ic>(stu+j+1)->c)||((stu+j)->c==(stu+j+1)->c)&&((stu+j)->s<(stu+j+1)->s)) + { + t = *(stu+j); + *(stu+j) = *(stu+j+1); + *(stu+j+1) = t; + } + } + } + return; +} + +int main() +{ + scanf("%d",&stu[3].num); + scanf("%d",&stu[3].c); + scanf("%f",&stu[3].m); + scanf("%f",&stu[3].p); + scanf("%f",&stu[3].e); + stu[3].x=1; + stu[3].s=stu[3].m+stu[3].p+stu[3].e; + int z=1,i,n=4; + for(i=0;i<3;i++) if(stu[i].num==stu[3].num) z=0; + if(z==0) n=3; + for(i=0;i<3;i++){ + if(stu[3].num==stu[i].num){ + printf("%d existed\n",stu[i].num); + return 0;}} + min(stu,n); + for(i=0;i