FJNUOJ 1002 画葫芦。。

画图就是。。找。。规。。律

#include <iostream>
using namespace std;
int main()
{
int T;
cin>>T;
while(T--)
{int n;
int width=1;
int lowHeight;
char r;
cin>>r>>n;
width+=n/6;
lowHeight=n/2-1;
for (int i = 0; i < n; ++i)
{
if(i==0||i==n-1||i==(n-1)/2)
{
for (int j = 0; j < lowHeight+width; ++j)
{
if(j<width)
cout<<' ';
else cout<<r;
}
}
else
{
for (int k = 0; k < width+lowHeight+width; ++k)
{
if(k<width)
cout<<r;
else if(k>=width&&k<width+lowHeight)
cout<<' ';
else cout<<r;
}
}
cout<<endl;
}
cout<<endl;
}
return 0;
}

原文地址:https://www.cnblogs.com/ruoh3kou/p/7802302.html