Aasha - Corner Elements of 4D Array
Single File Programming Question
Problem Statement
Aasha wants to write a program to print the four corner elements of a 2D array. These corners represent the elements at the extremities of the array.
Write a program that takes user input, processes the data and prints these corner elements.
Input:
format :The first line of input consists of an integer N, representing the number of rows.
The second line consists of an integer M, representing the number of columns.
The following lines N lines consist of M space-separated integers, representing the elements of the 2D array.
Output:
format :The output prints the corner elements of the 2D array, in the following format:
"Top-left: " followed by the top left corner element.
"Top-right: " followed by the top right corner element.
"Bottom-left: " followed by the bottom left corner element.
"Bottom-right: " followed by the bottom right corner element.
If the array does not have four corners (e.g., due to small dimensions), print "The array does not have four corners."
Refer to the sample output for formatting specifications.
Code constraints :
1 ≤ M, N ≤ 10
Sample test cases :
Input 1:
3 4 1 2 3 4 5 6 7 8 9 1 4 5
Output 1:
Top-left: 1 Top-right: 4 Bottom-left: 9 Bottom-right: 5
Input 2:
1 1 5
Output 2:
The array does not have four corners.
Note :
The program will be evaluated only after the “Submit Code” is clicked.
Extra spaces and new line characters in the program output will result in the failure of the test case.