求一个二维数组的最大值
本人新手,求大神解答在Max函数中为什么i一直等于3, 改不了
#include<stdio.h>
#define N 10
#define M 10
int Max(int a[][N], int m, int n);
void Print(int a[][N], int m, int n);
int main()
{
int a[M][N], i, j, max;
int m, n;
printf ("输入矩阵的行数和列数:\n");
scanf ("%d %d",&m,&n);
printf ("输入矩阵的元素:\n");
for (i = 0; i < m; i++)
{
for (j = 0; j < n; j++)
{
scanf ("%d",*(a+i)+j);
}
}
max = Max(a, m, n);
Print(a, m, n);
printf ("Max = %d",max);
return 0;
}
int Max(int a[][N], int m, int n)
{
int i, j, max;
max = a[0][0];
for (i = 0; i < m; i++);//这里的i为什么一直是 i = 3
{
for (j = 0; j < n; j++)
{
if (max <= a[i][j])
{
printf ("a[%d][%d] = %d ",i,j,a[i][j]);
max = a[i][j];
}
}
}
return max;
}
void Print(int a[][N], int m, int n)
{
int i,j;
for (i = 0; i < m; i++)
{
for (j = 0; j < n; j++)
printf ("%-5d",*(*(a+i)+j));
printf ("\n");
}
}