输入10个数输出数组最大数是第几个数和所有数的平均数

img


#include <stdio.h>
int main()
{
    int i,sum = 0;
    int a[10];
    for(i = 0;i < 10;i++){
        scanf("%d", &a[i]);
        sum += a[i];
    }
    int max = a[0],index = 0;
    for(i = 1;i < 10;i++){
        if(a[i] > max){
            max = a[i];
            index = i;
        }
    }
    printf("The greatest value is %d which is in index %d\n",max, index);
    printf("The average of the values in the array is %.3f\n", sum / 10.0);
    return 0;
}