How does this C for-loop print text-art pyramids?

后端 未结 10 1920
灰色年华
灰色年华 2021-02-05 04:24

This is my first time posting in here, hopefully I am doing it right.

Basically I need help trying to figure out some code that I wrote for class using C. The purpose o

10条回答
  •  遇见更好的自我
    2021-02-05 05:01

    Analyzing your loops:
    The first loop

    for ( int tall = 0; tall < user_i; tall++ ){...}
    

    is controlling the row. The second loop

    for ( int space = 0; space <= user_i - tall; space++ ){...}  
    

    for the column to be filled by spaces.
    For each row , it will fill all the user_i - tall columns with spaces.
    Now the remaining columns are filled by # by the loop

    for ( int hash = 0; hash <= tall; hash++ ){...}  
    

提交回复
热议问题