这个C语言的程序答案

实验题目:编制程序,其中函数fun(int(*p)[N],int m,int n, int *row, int xcolumn)的功能是查找二维数组的最大值 max 并用 return 语句返回,用参数回传最大值元素的行下标和列下标,并输出最大值及所在的行号和列号。

#include <stdio.h>
#define N 5
#define M 5

int fun(int (*p)[N], int m,int n, int *row, int *column)
{
    int b, c, s;
    int t = p[0][0];
    *row = 0;
    *column = 0;
    for (b = 0; b<M; b++)
        for (c = 0; c<N; c++)
            if (t < p[b][c]) {
                t = p[b][c];
                *row = b;
                *column = c;
            }
     return t;

}

int main()
{
    int a[M][N], b, c, x, y, s;
    for (b = 0; b<M; b++)
        for (c = 0; c<N; c++)
            scanf("%d",&a[b][c]);
    s = fun(a,M,N, &y, &x);
    printf("%d %d %d",s,y,x);
    return 0;
}

您好,我是有问必答小助手,您的问题已经有小伙伴解答了,您看下是否解决,可以追评进行沟通哦~

如果有您比较满意的答案 / 帮您提供解决思路的答案,可以点击【采纳】按钮,给回答的小伙伴一些鼓励哦~~

ps:问答VIP仅需29元,即可享受5次/月 有问必答服务,了解详情>>>https://vip.csdn.net/askvip?utm_source=1146287632