Description:
输入中含有若干组数据,每组数据由四部分组成,第一个是花纹字符,后面三个是整数,分别表示宽度(<80的奇数),高度(≤40)和重复度(≤20)。请编程画出该花纹。Sample Input:
W 9 17 1 E 15 6 2
Sample Output:
WWWWWWWWW W W W W W WWWWWWWWW W W W W W WWWWWWWWW W W W W W WWWWWWWWW W W W W W WWWWWWWWW W W W W W WWWWWWWWW W W W W W WWWWWWWWW W W W W W WWWWWWWWW W W W W W WWWWWWWWW EEEEEEEEEEEEEEE E E E E E E E E EEEEEEEEEEEEEEE E E E E E E E E EEEEEEEEEEEEEEE E E E E E E E E EEEEEEEEEEEEEEE E E E E E E E E EEEEEEEEEEEEEEE E E E E E E E E EEEEEEEEEEEEEEE
source:
#include <iostream>
using namespace std;
void print(int sp,char* pc)
{
int i;
for(i=0;i<sp;++i)
cout<<' ';
cout<<pc<<endl;
}
int main(int argc, char* argv[])
{
char c;
int w,h,re;
while(cin>>c>>w>>h>>re)
{
int i=0;
bool b=true;
char **pc=new char*[2];
pc[0]=new char[w+1];
pc[1]=new char[w+1];
for(i=0;i<w;++i)
{
pc[0][i]=c;
if((i+1)%2==0)
pc[1][i]=' ';
else
pc[1][i]=c;
}
pc[0][w]='\0';
pc[1][w]='\0';
i=0;
while(re>0)
{
for(;i<h/2;++i)
print(i,pc[int(b=!b)]);
if(h%2!=0)
print(h/2,pc[int(b=!b)]);
for(--i;i>=0;--i)
print(i,pc[int(b=!b)]);
--re;
i+=2;
}
cout<<endl;
delete pc[0];
delete pc[1];
delete pc;
}
return 0;
}