12102 - Dynamic 2D array   

Description

In this problem, you are asked to design two functions
    1.

unsigned** new_2d_array(unsigned n,unsigned m);

malloc an n*m 2D unsigned array, and then return its address. The main function will check the correctness of your array.

 

    2.

void delete_2d_array(unsigned **arr);

Free the memory space of your array that was previously allocated by using malloc. Be careful about the memory uage of your program allocated dynamically so as to avoid MLE.

 

The two functions have been declared in function.h, and you are asked to complete the function definitions in function.c.

Your program should construct the 2D array by using only two malloc function calls. Notice that malloc is a time-consuming operation.

 

Note: for OJ submission:

       Step 1. Submit only your function.c into the submission block. (Please choose C compiler) 

       Step 2. Check the results and debug your program if necessary.

Input

Please refer to the main function.

The input only has one line, consisting of four positive integers t,n,m,r separated by space characters, where t is the number of tests, (n,m) represents the array size, and r is a parameter for testing. 

Note that n*m<=100000000 and t*n*m<=100000000

Output

In order to test your array's correctness, we will use your array to do some computations and output the results.

Sample Input  Download

Sample Output  Download

Partial Judge Code

12102.c

Partial Judge Header

12102.h

Tags




Discuss