1、
#include <stdio.h>
int main(void)
{
int num;
int counts = 0, sum = 0;
int temp;
puts("please input an integer.");
printf("num = "); scanf("%d", &num);
while ( counts < num)
{
counts = ++counts;
printf("NO%d = ", counts); scanf("%d", &temp);
sum = sum + temp;
}
printf("sum = %d.\n", sum);
printf("mean = %f.\n", (double)sum / counts);
return 0;
}
↓
#include <stdio.h>
int main(void)
{
int num, temp;
int counts = 0, sum = 0;
puts("please input an num.");
printf("num = "); scanf("%d", &num);
while (counts < num)
{
printf("NO.%d = ", ++counts); scanf("%d", &temp);
sum = sum + temp;
}
printf("sum = %d.\n", sum);
printf("mean = %f.\n", (double)sum / counts);
return 0;
}