Computer Science, asked by nishanth9194, 5 hours ago

Write a program to enter a 2-D array of size n*n. Replace all the boundary elements by 0. Sort the non-boundary elements in ascending order using bubble sorting. Reprint the array in matrix form

Answers

Answered by tanishbh2007
0

Answer:

Input: M = 4, N = 5, Below is the given matrix:

1 2 3 4 0

1 1 1 1 2

1 2 2 2 4

1 9 3 1 7

Output:

0 1 1 1 1

9 1 1 1 1

7 2 2 2 2

4 4 3 3 2

Explanation:

For given matrix, border elements are:

(1, 2, 3, 4, 0, 2, 4, 7, 1, 3, 9, 1, 1, 1)

After sorting in clockwise order:

(0, 1, 1, 1, 1, 1, 2, 2, 3, 3, 4, 4, 7, 9)

Input: M = 3, N = 4

Similar questions