Basic Algorithm Review: Printing Pyramid

The final result picture is as follows:

To achieve this result, the usual approach is to join two triangles together, but in fact there is still a third triangle on the far right that has not been processed. This joining method always makes people look a little imperfect. , so I created an idea and synthesized it in one go. The code is as follows (this algorithm can effectively control three areas):

 

 

Guess you like

Origin blog.csdn.net/jnbbwyth/article/details/131147912