C++学习者,请帮我看一下这么解决这个问题好吗

来源:百度知道 编辑:UC知道 时间:2024/05/26 17:12:53
construct a C++ program which reads an integer ,n which is less than 10. Then ,using nested loop,display the triangle of * such as depicted in figure:
* * * * *
* * * *
* * *
* *
*
我是真心请求答案,在这边学电脑的只有我一个女生,所以有不会的地方也没有人可以讨论,请各位师哥师姐们帮一下我
谢了=^o^=

#include "iostream.h"
main()
{
int a,i,j;
cout<<"please in a number"<<endl;
cin>>a;

if(a>10)
cout<<"n which is less than 10"<<endl;
else
{

for(j=0;j<a;j++)
{
for(i=0;i<a-j;i++)
cout<<'*';
cout<<endl;
}
}
}

for(int line=0;line<5;line++)
{
for(int star=5-line;star>0;star--)
cout<<"*";
cout<<endl;
}

d