C语言高手请帮帮忙吧!!谢谢

来源:百度知道 编辑:UC知道 时间:2024/05/16 03:13:02
1、编写程序从键盘输入20个学生的成绩,求最高分、最低分和平均分。
2、编写一个程序,从键盘输入任意三位整数,将它们逆序输出。如:123,输出321。

#include <stdio.h>
#define NUM 3
int main()
{
int scores[NUM];
int i = 0;
int max = 0;
int min = 0;
int avg = 0;

while(i++ < NUM)
scanf("%d", &scores[i-1]);

max = min = scores[0];
for (i = 0; i< NUM; ++i)
{
if(min > scores[i])
min = scores[i];
if(max < scores[i])
max = scores[i];

avg += scores[i];
}

avg /= NUM;

printf("max=d%, min=%d, avg=%d",max,min,avg);

return 0;
///////////////////////////////////////////////////
#include <stdio.h>
#define NUM 3
int main()
{
int nums[NUM];
int i = 0;

while(i++ < NUM)
scanf("%d", &nums[i-1]);

for (i = NUM - 1; i >= 0; --i)
printf("%d",nums[i]);

return 0;
}