#include
using namespace std;
int main()
{
int a,n,i;
cout<<"请输入组成空心三角形的星号行数:";
cin>>a;
for (n=1; n<=a-1; n++)
cout<<" ";
cout<<"*"<
运行结果:
:
(2)图案(f):
#include
using namespace std;
int main()
{
int a,n,i;
cout<<"请输入组成空心三角形的星号行数:";
cin>>a;
for (n=1; n<=a; n++)
{
for (i=1; i<=a-n; i++)
cout<<" ";
for (i=1; i<=2*n-1; i++)
cout<<"*";
cout<