Puzzle L29


Print a square composed of four triangles

[H-12]Write a main() program that prints a square that consists of four triangles. The base of each triangle is a side of the square, as below. When there is an odd number of columns, the triangles meet at a point:

n==17 n==18
*****************
.***************.
..*************..
...***********...
....*********....
.....*******.....
......*****......
.......***.......
........*........
.......***.......
......*****......
.....*******.....
....*********....
...***********...
..*************..
.***************.
*****************
******************
.****************.
..**************..
...************...
....**********....
.....********.....
......******......
.......****.......
........**........
........**........
.......****.......
......******......
.....********.....
....**********....
...************...
..**************..
.****************.
******************

Getting this to work may take some fussing. Hint: think about the diagonal lines.



Previous Page        Answer         Next Page         Home