#include <
stdio.h>
#define ARRAY_LEN 5 /*数组长度*/
int main (void) {
int arr[ARRAY_LEN],max,min;
float sum,average;
int i;
printf ("请为%d个元素的一维数组输入内容:\n",ARRAY_LEN);
for (i=0; i<ARRAY_LEN; i++)
scanf ("%d",&arr[i]);
putchar ('\n');
min = max = arr[0];
sum = average = 0;
for (i=0; i<ARRAY_LEN; i++) {
if (arr[i]<min)
min = arr[i];
if (arr[i]>max)
max = arr[i];
sum += arr[i];
}
average = sum/ARRAY_LEN;
puts ("======================================================\n");
printf ("数组最大值:%d\n",max);
printf ("数组最小值:%d\n",min);
printf ("数组
平均值:%.2f\n",average);
getch (); /*屏幕暂留*/
return 0;
}
运行结果