
实验内容:把"*"与空格按特定的形状排列
源程序:
#include <iostream>
using namespace std;
int main()
{int i,j,l,n=6;
i=1;
while(i<=n)
{j=1;
while(j<=6-i)
{cout<<' ';
j=j+1;
}
l=1;
while(l<=2*i-1)
{cout<<'*';
l=l+1;
}
cout<<endl;
i=i+1;
}
return 0;
}
运行结果: