#include
main()
{
int num_max = 0; //最高分
int num_min = 0; //最低分
int num = 0; //接收输入分数
printf("请输入成绩:\n");
for(int i =0;i<10;i++)
{
scanf("%d",&num);
if(0 ==i)
{
num_max = num; //第一次输入为最高和最低分数赋值,方便以后判断
num_mix = num;
continue;
}
if(num_max < num)
{
num_max = num; //求最高分数
}
else if(num_min > num)
{
num_min = num; //求最低分数
}
}
printf("最高分数是:%d\n",num_max);
printf("最低分数是:%d\n",num_mix);
return 0;
}
这个还把平均分输出来了,你自己参考下吧,也可以自己根据需求改!
#include
main()
{
float score[10];//
float low,high,average,temp;
int i;
low=100;
average=0;
printf("please put into 10 people's score:\n");
for( i=0;i<10;i++)
{
printf("number %d people:",i+1);
scanf("%f",&temp);
if(temp>0 && temp<100)
{
score[i]=temp;
printf("\n");
if(score[i]<=low)
low=score[i];
if(score[i]>=high)
high=score[i];
average=average+score[i];
}
else
{
printf("the score error(score must between 0-100) \n");
i--;
}
}
average=average/10;
printf("the high score:%f\tthe lowe score:%f\taverage=%f",high,low,average);
}
书上很多这样的例子