P16219 [GeeksforGeeks] Triangle growing downwards2344
普及-
题目描述

Given string str of a constant length, print a triangle out of it. The triangle should start with the first character of the string and keep growing downwards by adding one character from the string.
The spaces on the left side of the triangle should be replaced with a dot character.
Example 1:
Input:
str = "geeks"
Output:
....g
...ge
..gee
.geek
geeks
Example 2:
Input:
str = "thisi"
Output:
....t
...th
..thi
.this
thisi
Your Task:
You don't need to read input. Your task is to complete the function printTriangleDownwards() which takes the string str as an input parameter and prints the required triangle.
Expected Time Complexity: O(N*N), Where N is the size of input string.
Expected Auxiliary Space: O(1)
Constraints:
1 <= |str| <= 500

输入格式

见题面

输出格式

见题面

样例输入
str = "geeks"
样例输出
....g ...ge ..gee .geek geeks