+ 6

How to create palindromic matrix by array ?

I have array contain nxn element type int , and i know it is palindromic matrix , and problem is how to create output is palindromic matrix ! input : 1 1 1 1 1 3 3 3 3 output : 1 3 1 3 1 3 1 3 1

2nd Mar 2019, 6:14 PM
Lê Tiến Nhật
Lê Tiến Nhật - avatar
4 Respostas
+ 4
Create groups of 8, 4 and a group of 1 element if it is an odd number. Then populate the matrix.
3rd Mar 2019, 12:14 AM
tamaslud
tamaslud - avatar
+ 3
Once you have the groups you may populate the topleft corner of the matrix. The center is from group 1 if odd, the axis from group of 4 and 8, the rest from 8. When ready copy it properly to the other three quarters.
3rd Mar 2019, 9:57 AM
tamaslud
tamaslud - avatar
+ 2
ok i understand ! thank u so much .
3rd Mar 2019, 9:59 AM
Lê Tiến Nhật
Lê Tiến Nhật - avatar
+ 1
thanks , but I need sort element to output ! not check again it right .
3rd Mar 2019, 2:03 AM
Lê Tiến Nhật
Lê Tiến Nhật - avatar