定义一个3×4的二维数组,随机产生20个整型数据(1000以内)并存储在该数组中,找出该数组的最大元素以及所在位置,输出数组的每行最大值和每列最大值。 #include "stdio.h" #include "stdlib.h" #include "time.h" #define M 3 //M用于表示数组行数 #define N 4 //N用于表示数组列数 void main() { int a[M][N], b[M], c[N], max, row, col, i, j; printf("随机产生的二维数组为:\n"); srand(time(NULL)); //双重循环遍历二维数组进行元素的输入 for (i=0; i
max) { max = a[i][j]; ; col = j; } } } //查找行最大值 for (i=0; i
b[i]) b[i] = a[i][j]; } } //查找列最大值 for (j=0; j
c[j]) ; } } printf("最大值为%d,位置:第%d行%d列\n", a[row][col], row+1, col+1); for (i=0; i