C语言课程设计课题求编程

来源:百度知道 编辑:UC知道 时间:2024/09/13 01:19:22
输入十个学生某一门课程的考试成绩,输出他们的平均成绩和最高成绩

#include<stdio.h>
void main()
{
float score[10],ave=0,max=0;
int i;
for(i=0;i<10;i++)
{
scanf("%f",&score[i]);
if(score[i]>max) max=score[i];
ave=ave+score[i];
}
ave=ave/10;
printf("average=%f max=%f\n",ave,max);
}

#include <stdio.h>

#define STUDENTSNUM (10)

void main()
{
int stu[STUDENTSNUM] = {0};
int max = 0;
int aver = 0;
int total = 0;
int i = 0;

for ( i = 0; i < STUDENTSNUM; i++ )
{
printf("The student%d's score is :", i + 1);
scanf("%d", &stu[i]);
if ( stu[i] > max )
{
max = stu[i];
}
total += stu[i];
}
aver = total / STUDENTSNUM;

printf("The average score is %d.\n", aver);
printf("The max is %d.\n"