选出成绩最好同学的成绩以及学号
#include<stdio。h>main(){ int N,i,j; int num[80]; float score[80]; int best_stu; /*the best score number of student*/ float best; /*the best score of student*/ printf("%s","please input the total num of students:\n"); scanf("%d",&N); printf("please input thes...全部
#include<stdio。h>main(){ int N,i,j; int num[80]; float score[80]; int best_stu; /*the best score number of student*/ float best; /*the best score of student*/ printf("%s","please input the total num of students:\n"); scanf("%d",&N); printf("please input these information:\n"); for(i=0;i<N;i++) { printf("num[%d]=",i); scanf("%d",&num[i]); printf("%s","score:"); scanf("%f",&score[i]); } printf("%s","the best students num is:\n"); best=score[0]; for(i=1;i<N;i++) { if(best<score[i]) { best=score[i]; best_stu=i; } } printf("%d ",num[best_stu]); printf("and her/his score is:\n"); printf("%。
2f",best); getch();}结果我已经在wintc中测试过了,没问题,只是你要注意的是num变量我定义的是int型,别越位就ok。哎 当年学c的时候,我咋就没想到这世界上还有个“百度-知道类!!!”好了 有什么关于C的问题尽管问我,我是做嵌入式的,嵌入式的问题也行问我。
收起