嘻嘻,这是我在学多重循环的时候写的。
代码有点长,请大家认真观看^_^
#include<iostream>
using namespace std;
int main()
{
int n=1,i,j,k,y,l;
for(i=1;i<=n;i++)
{
n++;
for(y=1;y<=n;y++)
{
for(j=1;j<=n-y;j++)
cout<<" ";
for(k=1;k<=2*y-1;k++)
cout<<"* ************";
cout<<endl;
}
for(y=1;y<=n;y++)
{
for(j=1;j<=y;j++)
cout<<" ";
for(k=1;k<=2*(n-i)-1;k++)
cout<<"# #";
for(l=1;l<=2*(n-i)-1;l++)
cout<<"$ $";
for(k=1;k<=2*(n-i)-1;k++)
cout<<"# #";
for(l=1;l<=2*(n-i)-1;l++)
cout<<"$ $";
for(k=1;k<=2*(n-i)-1;k++)
cout<<"# #";
for(l=1;l<=2*(n-i)-1;l++)
cout<<"$ $";
for(k=1;k<=2*(n-i)-1;k++)
cout<<"# #";
for(l=1;l<=2*(n-i)-1;l++)
cout<<"$ $";
for(k=1;k<=2*(n-i)-1;k++)
cout<<"# #";
for(l=1;l<=2*(n-i)-1;l++)
cout<<"$ $";
for(k=1;k<=2*(n-i)-1;k++)
cout<<"# #";
for(l=1;l<=2*(n-i)-1;l++)
cout<<"$ $";
for(k=1;k<=2*(n-i)-1;k++)
cout<<"# #";
for(l=1;l<=2*(n-i)-1;l++)
cout<<"$ $";
for(k=1;k<=2*(n-i)-1;k++)
cout<<"# #";
for(l=1;l<=2*(n-i)-1;l++)
cout<<"$ $";
for(k=1;k<=2*(n-i)-1;k++)
cout<<"# #";
for(l=1;l<=2*(n-i)-1;l++)
cout<<"$ $";
cout<<endl;
}
}
}