您好,下面的程序请参考,并在最后附有运行结果。
#include <stdlib.h>
#include <stdio.h>
void max(int a[][4], int k, int *x, int *y, int *z);
int main(void)
{
int a[3][4] = { {1, 2, 3, 4,},
{8, 12, 11, 10},
{5, 6, 7, 9}};
int m, n;
int num;
max(a, 3, &num, &m, &n);
printf("The max integer in array a is : a[%d][%d] = %d\n", m, n, num);
return 0;
}
void max(int a[][4], int k, int *x, int *y, int *z)
{
int i, j, m, n;
int num = a[0][0];
for(i = 0; i < k; i++){
for(j = 0; j < 4; j++){
if ( a[i][j] > num){
m = i;
n = j;
num = a[m][n];
}
}
}
*x = num;
*y = m;
*z = n;
}
feng@linux:~$ !g
gcc -Wall test.c
feng@linux:~$ ./a.out
The max integer in array a is : a[1][1] = 12
温馨提示:内容为网友见解,仅供参考