3247 - EE2310 Quiz 4 Scoreboard

Time

2025/10/13 11:00:00 2025/10/13 12:05:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
14757 Matrix maximum
14758 Pointer add function

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




14758 - Pointer add function   

Description

Write a program that defines a function add_n(iptr, n) to increase the value of an integer by a specified amount.

The function has the following behavior:

  • Parameters:

    • iptr: a pointer to an integer

    • n: an integer value to add

  • Function Rules:

    1. If iptr is NULL, the function should immediately return 0.

    2. If iptr is not NULL, the function increases the integer pointed to by iptr by n, and then returns the updated value.

Function to implement:

int add_n (int *iptr, int n);

Main program:

#include<stdio.h>
int add_n (int *iptr, int n);

int main(void)
{
    int i, j, k;

    scanf("%d%d", &i, &j);
    printf("i = %d\n", i);

    k = add_n(NULL, j);

    printf("i = %d, k = %d\n", i, k);

    k = add_n(&i, j);

    printf("i = %d, k = %d\n", i, k);

    return 0;
}

int add_n (int *iptr, int n)
{
    // Your Task
}

Your task is to implement the function add_n(iptr, n) and complete the main program.

Input

Two integers i and j.

Output

Three lines formatted as follows:

i = <i>

i = <i>, k = <k>

i = <i>, k = <k>

Here, <i> and <k> represent the output values.

Ensure that the output, including formatting and commas, exactly matches the provided samples.

Make sure the placement of space空格 and newline 換行 characters in your output is identical to the sample output.

Sample Input  Download

Sample Output  Download

Tags

11410EE 231002



Discuss