+ 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!
7 Réponses
+ 9
think i got it
https://code.sololearn.com/cP56nve6t4Ly/?ref=app
+ 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
+ 4
@davy thanks
+ 3
@alex danke....
muss dann ja lesbarer code sein
+ 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
+ 2
@alex: try enter 9:
24 is not a square. Back to the drawing table.
+ 2
Tried it myself with a different aproach.
Also tried to maintain a rectangular shape.
https://code.sololearn.com/c2r9OMgnq7hD/?ref=app