代码如下:
#include <stdio.h>
#include <stdlib.h>
#define M 3
#define N 3
int main()
{
int data[M][N], max, sum, i, j;
for (i = 0; i < M; i++) {
for (j = 0; j < N; j++) {
scanf("%d", &data[i][j]);
}
}
printf("\n");
for (i = 0; i < M; i++) {
max = data[i][0];
sum = 0;
for (j = 0; j < N; j++) {
if (data[i][j] > max)
max = data[i][j];
sum += data[i][j];
printf("%d ", data[i][j]);
}
printf("%d %d\n", max, sum);
}
system("pause");
return 0;
}
运行结果: