这里写了最基础的求二维数组的最大值,并输出其下标。写的不太好,希望自己慢慢进步吧。
#include<stdio.h>
int main()
{
int i, j, row = 0, colum = 0, max;
int a[3][4] = { 1,2,3,4,4,7,8,9,10,34,45,-2 };
max = a[0][0];
printf("please enter the array:\n");
for (i = 0; i < 3; i++)
{
for (j = 0; j < 4; j++)
{
printf("%d ", a[i][j]);
if (a[i][j] > max)
{
max = a[i][j];
row = i;
colum = j;
}
}
printf("\n");
}
printf("the max=%d\nrow=%d\ncolum=%d\n", max, row, colum);
return 0;
}