1、
#include <stdio.h>
#define NUMBER 5
int main(void)
{
int i;
int sum = 0;
int a[NUMBER];
puts("please input the scores.");
for (i = 0; i < NUMBER; i ++)
{
printf("NO.%d: ", i + 1);
scanf("%d", &a[i]);
sum += a[i];
}
printf("sum = %5d
", sum);
printf("mean = %5.1f
", (double)sum / NUMBER);
return 0;
}
↓
#include <stdio.h>
#define NUMBER 10
int main(void)
{
int i;
int sum = 0;
int a[NUMBER];
puts("please input the scores.");
for (i = 0; i < NUMBER; i ++)
{
printf("NO.%d: ", i + 1);
scanf("%d", &a[i]);
sum += a[i];
}
printf("sum = %5d
", sum);
printf("mean = %5.1f
", (double)sum / NUMBER);
return 0;
}