代码如下:
#include
#include
int main()
{
int i = 0, numbers[10] = { 0 }, max = 0, sum = 0;
float average = 0;
printf("请输入10个整数:");
for (i = 0; i < 10; i++) {
scanf("%d", &numbers[i]);
}
max = numbers[0];
for (i = 0; i < 10; i++) {
if (numbers[i] > max) {
max = numbers[i];
}
sum += numbers[i];
}
average = sum / 10.0;
printf("最大值:%d, 总和:%d, 平均值:%.2f\n", max, sum, average);
system("pause");
return 0;
}
运行结果: