+ 7

🔔🔔 CHALLENGE: TOWER OF SQUARES 🔔🔔

Write a code that displays the tower of squares for a given number as a matrix. A tower of squares is a tower with square base. The outer square has height 1, the next one height 4, than 9 and so on. n=1 1 n=2 11 11 n=3 111 141 111 n=4 1111 1441 1111 n=5 11111 14441 14941 14441 11111 Have fun coding!

10th Feb 2018, 8:47 PM
davy hermans
davy hermans - avatar
7 odpowiedzi
10th Feb 2018, 9:29 PM
Oma Falk
Oma Falk - avatar
+ 4
Made the mistake to take a quick look at Oma falk's solution. So mine is heavily influenced by falk's :p Great job! https://code.sololearn.com/cD1tXfX1j8EG/?ref=app
10th Feb 2018, 10:09 PM
Alex
Alex - avatar
+ 4
@davy thanks
11th Feb 2018, 3:38 PM
Oma Falk
Oma Falk - avatar
+ 3
@alex danke.... muss dann ja lesbarer code sein
10th Feb 2018, 10:16 PM
Oma Falk
Oma Falk - avatar
+ 3
Fixed it. And here is another version with a different approach. Made a dynamic 2d-array and filled it multiple times with decrementing iterators in the nested for loops. https://code.sololearn.com/cD1tXfX1j8EG/?ref=app https://code.sololearn.com/c8xVYIOciJq8/#cpp
10th Feb 2018, 11:52 PM
Alex
Alex - avatar
+ 2
@alex: try enter 9: 24 is not a square. Back to the drawing table.
10th Feb 2018, 10:20 PM
davy hermans
davy hermans - avatar
+ 2
Tried it myself with a different aproach. Also tried to maintain a rectangular shape. https://code.sololearn.com/c2r9OMgnq7hD/?ref=app
11th Feb 2018, 7:51 AM
davy hermans
davy hermans - avatar