diff --git a/step_3.c b/step_3.c new file mode 100644 index 0000000..e28b094 --- /dev/null +++ b/step_3.c @@ -0,0 +1,89 @@ +int main() +{ + printf(" 1.Input\n"); + printf(" 2.Output\n"); + printf(" 3.Order\n"); + printf(" 4.Quit\n"); + char c; + scanf("%c",&c); + if(c=='i'){printf("You are trying to Input info:\n");} + if(c=='o'){printf("You are trying to Output info");} + if(c=='m'){printf("You are trying to Make things ordered");} + if(c=='q'){printf("You are about to Quit");} + if(c!='i'&&c!='o'&&c!='m'&&c!='q'){printf("Wrong input");} +struct student{ + int study; + float math; + float physics; + float English; + float all; +}student1,student2,student3; +if(c=='i'){ + scanf("%d%f%f%f ",&student1.study,&student1.math,&student1.physics,&student1.English); +scanf("%d%f%f%f ",&student2.study,&student2.math,&student2.physics,&student2.English); +scanf("%d%f%f%f",&student3.study,&student3.math,&student3.physics,&student3.English);} +student1.all=student1.math+student1.physics+student1.English; +student2.all=student2.math+student2.physics+student2.English; +student3.all=student3.math+student3.physics+student3.English; +float*s1;float*s2;float*s3; +s1=&student1.all; +s2=&student2.all; +s3=&student3.all; +float ping=(*s1+*s2+*s3)/3; +float two; +float max(float*k1,float*k2,float*k3);//比较三者 +float max2(float*k1,float*k2);//比较二者 +float z=max(s1,s2,s3); +if(z==*s1){ + printf("%d,%2.1f,%2.1f,%2.1f,%2.1f,%2.1f\n",student1.study,student1.all,ping,student1.math,student1.physics,student1.English); + two=max2(s2,s3); + if(two==*s2){ + printf("%d,%2.1f,%2.1f,%2.1f,%2.1f,%2.1f\n",student2.study,student2.all,ping,student2.math,student2.physics,student2.English); + printf("%d,%2.1f,%2.1f,%2.1f,%2.1f,%2.1f\n",student3.study,student3.all,ping,student3.math,student3.physics,student3.English); + } + else{ + printf("%d,%2.1f,%2.1f,%2.1f,%2.1f,%2.1f\n",student3.study,student3.all,ping,student3.math,student3.physics,student3.English); + printf("%d,%2.1f,%2.1f,%2.1f,%2.1f,%2.1f\n",student2.study,student2.all,ping,student2.math,student2.physics,student2.English); +}; +} +if(z==*s2){ + printf("%d,%2.1f,%2.1f,%2.1f,%2.1f,%2.1f\n",student2.study,student2.all,ping,student2.math,student2.physics,student2.English); + two=max2(s1,s3); + if(two==*s1){ + printf("%d,%2.1f,%2.1f,%2.1f,%2.1f,%2.1f\n",student1.study,student1.all,ping,student1.math,student1.physics,student1.English); + printf("%d,%2.1f,%2.1f,%2.1f,%2.1f,%2.1f\n",student3.study,student3.all,ping,student3.math,student3.physics,student3.English); + } + else{ + printf("%d,%2.1f,%2.1f,%2.1f,%2.1f,%2.1f\n",student3.study,student3.all,ping,student3.math,student3.physics,student3.English); + printf("%d,%2.1f,%2.1f,%2.1f,%2.1f,%2.1f\n",student1.study,student1.all,ping,student1.math,student1.physics,student1.English); + }; +} +if(z==*s3){ + printf("%d,%2.1f,%2.1f,%2.1f,%2.1f,%2.1f\n",student3.study,student3.all,ping,student3.math,student3.physics,student3.English); + two=max2(s2,s1); + if(two==*s1){ + printf("%d,%2.1f,%2.1f,%2.1f,%2.1f,%2.1f\n",student1.study,student1.all,ping,student1.math,student1.physics,student1.English); + printf("%d,%2.1f,%2.1f,%2.1f,%2.1f,%2.1f\n",student2.study,student2.all,ping,student2.math,student2.physics,student2.English); + } + else{ + printf("%d,%2.1f,%2.1f,%2.1f,%2.1f,%2.1f\n",student2.study,student2.all,ping,student2.math,student2.physics,student2.English); + printf("%d,%2.1f,%2.1f,%2.1f,%2.1f,%2.1f\n",student1.study,student1.all,ping,student1.math,student1.physics,student1.English); + }; +} +return 0; +} + float max(float*k1,float*k2,float*k3) +{ + float l; + if(*k1>*k2&&*k1>*k3){l=*k1;} + if(*k2>*k3&&*k2>*k1){l=*k2;} + if(*k3>*k1&&*k3>*k2){l=*k3;} + return(l); +} +float max2(float *k1,float *k2) +{ + float l; + if(*k1>*k2){l=*k1;} + if(*k2>*k1){l=*k2;} + return(l); +} \ No newline at end of file