题目链接
题目描述
输入一个n,输出n层图形,见下(图为n=4的情况):
*
**
***
****
Input
输入一个数n
Output
输出相应的图形
Sample Input
6
Sample Output
*
**
***
****
*****
******
思路
输入一个数n,输出n行的图形,每1行有1个*,第二行有2个*,……第n行有n个*。
C++代码:
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
while(cin >> n)
{
for(int i = 1; i <= n; i++)
{
for(int j = 1; j <= i; j++)
cout << "*";
cout << endl;
}
}
return 0;
}