14757 - Matrix maximum   

Description

This program reads a 4×4 integer matrix and finds the largest value within it.
You are required to implement a function max that takes a 4×4 integer array as input and returns the maximum value among all elements.

Function to implement:

int max(int array[4][4]);

Main program:

#include<stdio.h>
#define N 4
int max(int array[N][N]);
int main(void)
{
    int i;
    int j;
    int array[N][N];

    for (i = 0; i < N; i++) {
        for (j = 0; j < N; j++) {
            scanf("%d", &(array[i][j]));
        }
    }

    printf("%d\n", max(array));

    return 0;
}

int max(int array[N][N])
{
    // Your Task
}

Your task is to implement the function max(int array[4][4]) and complete the main program.

Hint

Arrays cannot be directly passed by value in C.
You must use pointers to access the elements within the 2D array inside your function.

Input

Sixteen integers, representing the elements of a 4×4 matrix in row-major order.

Output

One integer — the maximum value in the matrix.

Ensure that the output, including formatting 輸出格式, exactly matches the provided samples.

Sample Input  Download

Sample Output  Download

Tags

11410EE 231002



Discuss