#include "stdafx.h"
int main()
{
const int a = 3;
const int b = 3;
int arr[a][b] = {0};
for (int i = 0; i <= a - 1; i++)
{
for (int j = 0; j <= b - 1; j++)
{
scanf_s("%d", &arr[i][j]);
}
}
int sum = 0, pjz = 0;//总和与平均值
int n = sizeof(arr) / sizeof(int);//数组一共有几个数
for (int i = 0; i <= a - 1; i++)
{
for (int j = 0; j <= b - 1; j++)
{
sum = arr[i][j] + sum;//计算总和
}
}
printf("平均值为:%d\n", sum / n);//输出平均值
int max = arr[0][0];//最大值
int min = arr[0][0];//最小值
for (int i = 0; i <= a - 1; i++)
{
for (int j = 0; j <= b - 1; j++)
{
if (arr[i][j] > max)
{
max = arr[i][j];//判断最大值
}
if (arr[i][j] < min)
{
min = arr[i][j];//判断最小值
}
}
}
printf("最大值为:%d,最小值为:%d", max, min);//输出最大最小值
return 0;
}
原文:http://www.cnblogs.com/xiaoj-/p/7896362.html