#K39922. Construct Right-Angled Triangles
Construct Right-Angled Triangles
Construct Right-Angled Triangles
Given a list of non-negative integers representing the heights of right-angled triangles, construct each triangle by printing rows of asterisks. For a triangle of height \(H\), the \(i\)-th row should contain \(i\) asterisks for \(1 \leq i \leq H\).
If the height is 0, no output is produced for that triangle. The triangles must be printed in the same order as they appear in the input, with a blank line separating consecutive triangles. The output should end with a newline.
Mathematically, the triangle for a given height \(H\) can be represented as:
$$ T(H)=\{\,a_i = \underbrace{*\, *\, \cdots\,*}_{i} \;\big|\; 1 \leq i \leq H\} $$inputFormat
The first line contains an integer \(N\), the number of triangles. The second line contains \(N\) space-separated non-negative integers representing the heights of the triangles.
outputFormat
For each positive height, output its corresponding right-angled triangle where the \(i\)-th row contains exactly \(i\) asterisks. Consecutive triangles should be separated by a blank line. The output must end with a newline character.
## sample4
3 5 2 0
*
**
**
**
</p>