Problems
10075 - Boundary
SUBMIT PROBLEM

Boundary

Time Limit: 0.5 sec

 

The Problem

An array keeps track of multiple pieces of information in linear order, a one-dimensional list. However, the data associated with certain systems (a digital image, a board game, etc.) lives in two dimensions. To visualize this data, we need a multi-dimensional data structure, that is, a multi-dimensional array. A two-dimensional array is really nothing more than an array of arrays. Think of your dinner. You could have a one-dimensional list of everything you eat:

(lettuce, tomatoes, steak, mashed potatoes, cake, ice cream)

Or you could have a two-dimensional list of three courses, each containing two things you eat:

(lettuce, tomatoes) and (steak, mashed potatoes) and (cake, ice cream)

Write a program that takes a 2-D array of size ‘m*n’ and print its boundary (border) elements.

 

The Input

The file contains two positive integer m & n (m = rows, n = columns numbers). Input is terminated, when m=0 and n=0. Next m line contains n integer values.

 

The Output

Horizontal Tab spaces separate the boundary elements. Two consecutive test case are separated by a blank line.

 

Sample Input

4 5

11 12 13 14 15

16 17 18 19 20

21 22 23 24 25

26 27 28 29 30

0 0

 

Sample Output

11        12        13        14        15

16                                            20

21                                            25

26        27        28        29        30

 

 

 

Inter University Mock Contest - 2016 [BGC Trust University Bangladesh]

Problem Setter:  Bishwajit Barua