编程C语言 怎么写1已知一个班20个学生的成绩,存放在一个一维数组中,要求找出其中

编程C语言 怎么写1已知一个班20个学生的成绩,存放在一个一维数组中,要求找出其中成绩最高的学生成绩和该生的序号。

#include "stdio.h"
#include <stdlib.h>
#include "time.h"
int main(int argv,char *argc[]){
char s[20],i,m;
srand((unsigned)time(NULL));
printf("Students' scores are as follows:\n");
for(m=i=0;i<20;i++){
printf("%-4d",s[i]=rand()%100+1);//模拟输入20人的成绩
if(s[m]<s[i])//寻找最高分的下标
m=i;
}
printf("\n\nMAX = %d\tSUB = %d\n",s[m],m);//输出最高分和下标
return 0;
}

执行样例如下:

温馨提示:答案为网友推荐,仅供参考
第1个回答  2014-12-16
具体数据结构如下:
typedef struct stScore
{
unsigned short usNo; //学号
unsigned short usScore; //得分
}STUDENT;
//得分、学号的student的结构体数组定义
STUDENT staStudentScore[20];本回答被网友采纳
相似回答