#include<stdio.h>struct student//xueheng{ char name[20]; int age; int num; float score[6];}; struct student a[5] ; int i,j,k;void shuru(){ for(j=0;j<5;j++) //非你别输入5个学生年龄 { scanf("%s",a[j].name); scanf("%d",&a[j].age); scanf("%d",&a[j].num); for(i=0;i<4;i++) scanf("%f",&a[j].score[i]);//4学生成绩门课 } k=1; scanf("%d",&k);}void zongfen(){ for(j=0;j<5;j++) { a[j].score[4]=a[j].score[0]+a[j].score[1]+a[j].score[2]+a[j].score[3]; a[j].score[5]=a[j].score[4]/4.0;//求平均分 } k=2;} void paixu() { k=3; for(j=1;j<5;j++) for(i=0;i<=4-j;i++) { if(a[i].score[4]>a[i+1].score[4])//非别比较5个学生4门可总成绩大小排序 { struct student temp; temp =a[i]; a[i] =a[i+1]; a[i+1] = temp; } } }void shuchu(){ k=4; for(j=0;j<5;j++) { printf(" %s",a[j].name); printf(" %d",a[j].age); printf(" %d",a[j].num); for(i=0;i<6;i++) printf(" %.1f",a[j].score[i]); printf("\n"); }}void main(){int k;do{printf("----1输入------\n");printf("----2总分------\n");printf("----3排序------\n");printf("----4输出-----\n");printf("请输入你的选择");scanf("%d",&k);switch(k){ case 1: if(k==1) { shuru(); break; } case 2: if(k==2) zongfen(); else if(k==1) shuru(); else break; case 3: if(k==3) paixu(); else if(k=2) zongfen(); else if(k==1) shuru(); else break; case 4: if(k==4) shuchu(); else if(k==3) paixu(); else if(k=2) zongfen(); else if(k==1) shuru(); else break; }}while(k!=5);}#include<stdio.h>struct student//xueheng{ char name[20]; int age; int num; float score[6];}; struct student a[5] ; int i,j,k;void shuru(){ for(j=0;j<5;j++) //非你别输入5个学生年龄 { scanf("%s",a[j].name); scanf("%d",&a[j].age); scanf("%d",&a[j].num); for(i=0;i<4;i++) scanf("%f",&a[j].score[i]);//4学生成绩门课 } k=1; scanf("%d",&k);}void zongfen(){ for(j=0;j<5;j++) { a[j].score[4]=a[j].score[0]+a[j].score[1]+a[j].score[2]+a[j].score[3]; a[j].score[5]=a[j].score[4]/4.0;//求平均分 } k=2;} void paixu() { k=3; for(j=1;j<5;j++) for(i=0;i<=4-j;i++) { if(a[i].score[4]>a[i+1].score[4])//非别比较5个学生4门可总成绩大小排序 { struct student temp; temp =a[i]; a[i] =a[i+1]; a[i+1] = temp; } } }void shuchu(){ k=4; for(j=0;j<5;j++) { printf(" %s",a[j].name); printf(" %d",a[j].age); printf(" %d",a[j].num); for(i=0;i<6;i++) printf(" %.1f",a[j].score[i]); printf("\n"); }}void main(){int k;do{printf("----1输入------\n");printf("----2总分------\n");printf("----3排序------\n");printf("----4输出-----\n");printf("请输入你的选择");scanf("%d",&k);switch(k){ case 1: if(k==1) { shuru(); break; } case 2: if(k==2) zongfen(); else if(k==1) shuru(); else break; case 3: if(k==3) paixu(); else if(k=2) zongfen(); else if(k==1) shuru(); else break; case 4: if(k==4) shuchu(); else if(k==3) paixu(); else if(k=2) zongfen(); else if(k==1) shuru(); else break; }}while(k!=5);}#include<stdio.h>struct student//xueheng{ char name[20]; int age; int num; float score[6];}; struct student a[5] ; int i,j,k;void shuru(){ for(j=0;j<5;j++) //非你别输入5个学生年龄 { scanf("%s",a[j].name); scanf("%d",&a[j].age); scanf("%d",&a[j].num); for(i=0;i<4;i++) scanf("%f",&a[j].score[i]);//4学生成绩门课 } k=1; scanf("%d",&k);}void zongfen(){ for(j=0;j<5;j++) { a[j].score[4]=a[j].score[0]+a[j].score[1]+a[j].score[2]+a[j].score[3]; a[j].score[5]=a[j].score[4]/4.0;//求平均分 } k=2;} void paixu() { k=3; for(j=1;j<5;j++) for(i=0;i<=4-j;i++) { if(a[i].score[4]>a[i+1].score[4])//非别比较5个学生4门可总成绩大小排序 { struct student temp; temp =a[i]; a[i] =a[i+1]; a[i+1] = temp; } } }void shuchu(){ k=4; for(j=0;j<5;j++) { printf(" %s",a[j].name); printf(" %d",a[j].age); printf(" %d",a[j].num); for(i=0;i<6;i++) printf(" %.1f",a[j].score[i]); printf("\n"); }}void main(){int k;do{printf("----1输入------\n");printf("----2总分------\n");printf("----3排序------\n");printf("----4输出-----\n");printf("请输入你的选择");scanf("%d",&k);switch(k){ case 1: if(k==1) { shuru(); break; } case 2: if(k==2) zongfen(); else if(k==1) shuru(); else break; case 3: if(k==3) paixu(); else if(k=2) zongfen(); else if(k==1) shuru(); else break; case 4: if(k==4) shuchu(); else if(k==3) paixu(); else if(k=2) zongfen(); else if(k==1) shuru(); else break; }}while(k!=5);}
目前暂无任何回答
- 0 回答
- 0 关注
- 1230 浏览
添加回答
举报
0/150
提交
取消