#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
void show(int arr[][5], int n);
void mean_1(int arr[][5], int n);
void mean_2(int arr[][5], int n);
void max(int arr[][5], int n);
void print_r(int arr[][5], int n);
int main(void)
{
int n,t=0;
int arr[3][5];
printf("请输入3组数,每组包含5个数\n");
while (scanf("%d", &n) == 1&&t<15)
{
arr[t/5][t%5] = n;
//printf("%d %d %d\n", n,t/5,t%5);
t += 1;
}
print_r(arr, 3);
return 0;
}
void show(int arr[][5], int n)
{
for (int i = 0; i < n; i++)
{
for (int j = 0; j < 5; j++)
printf("%-3d", arr[i][j]);
putchar('\n');
}
return;
}
void mean_1(int arr[][5], int n)
{
double mean_1=0;
for (int i = 0; i < n; i++)
{
for (int j = 0; j < 5; j++)
mean_1 += arr[i][j];
printf("第%d组平均值为:%lf\n", i + 1, (double)mean_1 / 5);
mean_1 = 0;
}
return;
}
void mean_2(int arr[][5], int n)
{
double mean_2 = 0;
for (int i = 0; i < n; i++)
{
for (int j = 0; j < 5; j++)
mean_2 += arr[i][j];
}
printf("平均值为:%lf\n",(double)mean_2 / 15);
return;
}
void max(int arr[][5], int n)
{
int max;
max = **arr;
for (int i = 0; i < n; i++)
for (int j = 0; j < 5; j++)
max = max > arr[i][j] ? max : arr[i][j];
printf("最大值为:%d\n", max);
}
void print_r(int arr[][5], int n)
{
show(arr, n);
mean_1(arr, n);
mean_2(arr, n);
max(arr, n);
return;
}