From 93365bf730e33f4457419f08bbacefca26c42a57 Mon Sep 17 00:00:00 2001 From: powf2zncv <3313430869@qq.com> Date: Wed, 15 Nov 2023 22:40:30 +0800 Subject: [PATCH] Update README.md --- README.md | 182 +++++++++++++++++------------------------------------- 1 file changed, 58 insertions(+), 124 deletions(-) diff --git a/README.md b/README.md index 1af57ae..51d6a71 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,7 @@ int main() printf("%d %.1f %.1f %.1f %.1f\n",num[i],math[i],physic[i],english[i],sum[i]); } } + 步骤3 int main() { @@ -204,7 +205,7 @@ for(int j=0;j +#include #include #include int num[4],cla[4]; @@ -286,7 +287,8 @@ n=m+1; sta=0;begin=sta; sort(add); n=3; - scanf("delete"); + //scanf("delete"); + printf("请输入要删除的学生信息(学号或姓名)\n"); scanf("%s",name[3]); int exist=0,target; if(name[3][0]>='0'&&name[3][0]<='9') @@ -294,7 +296,7 @@ n=3; int number=atoi(name[3]); for(int i=0;i<3;i++){ if(number==num[i]){ - printf("Are you sure?"); + printf("Are you sure(yes)?\n"); exist=1; target=i; break; @@ -306,7 +308,7 @@ n=3; for(int i=0;i<3;i++){ if(strcmp(name[i],name[3])); else{ - printf("Are you sure?\n"); + printf("Are you sure(yes)?\n"); exist=1; target=i; break; @@ -335,134 +337,66 @@ n=3; } } return 0; - } + } 步骤六 -#include -#include -#include -int num[4],cla[4]; -float f[4],s[4],t[4],add[4]; -int begin,sta; -int n=3; -int insert; -char name[4][10]={{"Zhang"},{"Yang"},{"Liang"}}; -void sort(float add[]) -{ - int i,j,te; - float zh; - char oo[10]; - for(i=n-1;i>sta;i--) - { - if(add[i]>add[i-1]) - { - zh=add[i];add[i]=add[i-1];add[i-1]=zh; - te=num[i];num[i]=num[i-1];num[i-1]=te; - zh=f[i];f[i]=f[i-1];f[i-1]=zh; - zh=s[i];s[i]=s[i-1];s[i-1]=zh; - zh=t[i];t[i]=t[i-1];t[i-1]=zh; - strcpy(oo,name[i]);strcpy(name[i],name[i-1]); - strcpy(name[i-1],oo); - } +#include +struct Scoreb{ + int schoolnumber; + int classnumber; + char name[20]; + float math; + float physics; + float english; + float sum; +}; +int main(){ +struct Scoreb student1={10001,11,"Zhang",99.5,88.5,89.5,277.5}; + struct Scoreb student2={10002,12,"Yang",77.9,56.5,87.5,221.9}; + struct Scoreb student3={10003,11,"Liang",92.5,99.0,60.5,252}; + struct Scoreb students[3] = {student1,student2,student3}; + + struct Scoreb schange; + scanf("%d%d%s%f%f%f",&schange.schoolnumber,&schange.classnumber,&schange.name,&schange.math,&schange.physics,&schange.english);int c=schange.schoolnumber; + for(int i=0;i<3;i++){ + if(schange.schoolnumber==students[i].schoolnumber){ + schange.sum = schange.math+schange.physics+schange.english; + students[i]=schange; + } } - if(n!=sta+1) - { - sta++; - sort(add);} -} -void div(int clas[]) -{ - int i,j,te; - float zh; - char oo[10]; - for(i=0;iclas[i+1]) - { - te=clas[i];clas[i]=clas[i+1];clas[i+1]=te; - zh=add[i];add[i]=add[i+1];add[i+1]=zh; - te=num[i];num[i]=num[i+1];num[i+1]=te; - zh=f[i];f[i]=f[i+1];f[i+1]=zh; - zh=s[i];s[i]=s[i+1];s[i+1]=zh; - zh=t[i];t[i]=t[i+1];t[i+1]=zh; - strcpy(oo,name[i]);strcpy(name[i],name[i+1]); - strcpy(name[i+1],oo); + for(int j = 0 ; j < 3 ; j++) + for(int k = 2; k > j;k--){ + if(students[k].classnumber students[k-1].sum){ + struct Scoreb temp2 = students[k-1]; + students[k-1] = students[k]; + students[k] = temp2; + } + } } + + for(int i = 0; i < 2 ; i++){ + printf("%d %d %s %.1f %.1f %.1f ",students[i].classnumber,students[i].schoolnumber,students[i].name,students[i].math,students[i].physics,students[i].english); + if(c==students[i].schoolnumber) + printf("modified\n"); + if(students[0].classnumber==students[1].classnumber) + { + printf(" %d %s %.1f %.1f %.1f\n",students[1].schoolnumber,students[1].name,students[1].math,students[1].physics,students[1].english);break;} } - if(n!=sta+1){ - n--; - div(clas);} + printf("%d %d %s %.1f %.1f %.1f\n",students[2].classnumber,students[2].schoolnumber,students[2].name,students[2].math,students[2].physics,students[2].english); + if(c==students[2].schoolnumber) + printf(" modified"); + return 0; } - -int main() -{ -void sort(float add[]); -void div(int clas[]); -num[0]=10001;num[1]=10002;num[2]=10003; -cla[0]=11;cla[1]=12;cla[2]=11; -f[0]=99.5;f[1]=77.9;f[2]=92.5; -s[0]=88.5;s[1]=56.5;s[2]=99.0; -t[0]=89.5;t[1]=87.5;t[2]=60.5; -sta=0;begin=0; -div(cla); -n=3; -int m; -for(m=0;m #include