【题目描述】
对于给定的自然数n(n<20)n(n<20),在屏幕上输出仅由“*
”构成的nn行的直角三角形。
【输入】
输入nn。
【输出】
题述三角形。
【输入样例】
5
【输出样例】
*
**
***
****
*****
【代码】
#include<iostream>
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;
}
return 0;
}
【做题链接】
信息学奥赛一本通(C++版)在线评测系统 (ssoier.cn)http://ybt.ssoier.cn:8088/problem_show.php?pid=2027
【加入群聊】
如果大家有问题可以加群568758792