From c70637efed67b793a83741ccf0c43f6db590a838 Mon Sep 17 00:00:00 2001 From: pbs89iory Date: Sat, 11 Nov 2023 23:07:55 +0800 Subject: [PATCH] Update README.md --- README.md | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/README.md b/README.md index 7c0e65f..25afb4a 100644 --- a/README.md +++ b/README.md @@ -21,3 +21,83 @@ int main( ) } +#include +int main( ) +{ struct Student + { + int xh; + float gs; + float dw; + float yy; + float zcj; + } student1,student2,student3; + scanf("%d%f%f%f",&student1.xh,&student1.gs,&student1.dw,&student1.yy); + scanf("%d%f%f%f",&student2.xh,&student2.gs,&student2.dw,&student2.yy); + scanf("%d%f%f%f",&student3.xh,&student3.gs,&student3.dw,&student3.yy); + student1.zcj=student1.gs+student1.dw+student1.yy; + student2.zcj=student2.gs+student2.dw+student2.yy; + student3.zcj=student3.gs+student3.dw+student3.yy; + printf("学号 %d 高数成绩 %.1f 大学物理成绩 %.1f 英语成绩 %.1f 总成绩 %.1f\n",student1.xh,student1.gs,student1.dw,student1.yy,student1.zcj); + printf("学号 %d 高数成绩 %.1f 大学物理成绩 %.1f 英语成绩 %.1f 总成绩 %.1f\n",student2.xh,student2.gs,student2.dw,student2.yy,student2.zcj); + printf("学号 %d 高数成绩 %.1f 大学物理成绩 %.1f 英语成绩 %.1f 总成绩 %.1f\n",student3.xh,student3.gs,student3.dw,student3.yy,student3.zcj); +} + +#include +int main( ) +{ + int num_spaces =30; + printf("%*s1.Input\n",num_spaces," "); + printf("%*s2.Output\n",num_spaces," "); + printf("%*s3.Order\n",num_spaces," "); + printf("%*s4.Quit\n",num_spaces," "); + char a; + again:a=getchar(); + switch(a) + { + case'i':printf("Please input info of the three students:"); + struct Student + { + int xh; + float gs; + float dw; + float yy; + float zcj; + float pjf; + } student1,student2,student3,studenttemp; + scanf("%d%f%f%f",&student1.xh,&student1.gs,&student1.dw,&student1.yy); + scanf("%d%f%f%f",&student2.xh,&student2.gs,&student2.dw,&student2.yy); + scanf("%d%f%f%f",&student3.xh,&student3.gs,&student3.dw,&student3.yy); + student1.zcj=student1.gs+student1.dw+student1.yy; + student2.zcj=student2.gs+student2.dw+student2.yy; + student3.zcj=student3.gs+student3.dw+student3.yy; + student1.pjf=student1.zcj/3; + student2.pjf=student2.zcj/3; + student3.pjf=student3.zcj/3; + if(student2.zcj>student3.zcj) + { + studenttemp = student2; + student2 = student3; + student3 = studenttemp; + } + if(student1.zcj>student3.zcj) + { + studenttemp = student1; + student1 = student3; + student3 = studenttemp; + } + if(student1.zcj>student2.zcj) + { + studenttemp = student1; + student1 = student2; + student2 = studenttemp; + } + printf("%d,%.1f,%.1f\n%d,%.1f,%.1f\n%d,%.1f,%.1f\n",student1.xh,student1.zcj,student1.pjf,student2.xh,student2.zcj,student2.pjf,student3.xh,student3.zcj,student3.pjf); + break; + case'o':printf("You are trying to Output info");break; + case'm':printf("You are trying to Make things orderd");break; + case'q':printf("You are about to Quit");break; + case'\n':printf("\n");break; + default:printf("Wrong input"); + } + goto again; +}