2027:【例4.13】三角形
时间限制: 1000 ms 内存限制: 65536 KB
提交数:55765 通过数: 43533
【题目描述】
对于给定的自然数n(n<20)n(n<20),在屏幕上输出仅由“*
”构成的nn行的直角三角形。
【输入】
输入nn。
【输出】
题述三角形。
【输入样例】
5
【输出样例】
*
**
***
****
*****
#include "bits/stdc++.h"
using namespace std;
int main()
{
int n;
cin >> n;
for (int i=1;i<=n;i++)
{
for (int j=1;j<=i;j++)
{
cout<<"*";
}
cout<<endl;
}
}