题目描述
人们都喜欢8这个数字,手机号希望全是8,车牌号也希望全是8.在这个无发不在的世界,8俨然成为了人们发财的数字。为了以后我们的前途,大家来画8吧,谁画的标准,好看,谁的前途就越好。
输入格式
多组测试数据。每组中有一个字符c(大写字母或者小写字母)和一个整数n,字符表示画笔,整数表示高度。,(5<=n<=20).
输出
画横线总是一个字符粗,竖线随着总高度每增长6而增加1个字符宽.当总高度从5增加到6时,其竖线宽度从1增长到2.下圈高度不小于上圈高度,但应尽量接近上圈高度,且下圈的内径呈正方形.
样例输入
A 7
B 8
样例输出
AA
AA AA
AA AA
AA
AA AA
AA AA
AA
BBB
BB BB
BB BB
BBB
BB BB
BB BB
BB BB
BBB
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
char c;
int n;
int W;
int h1,h2;
while(cin>>c>>n)
{
h1=h2=(n-3)/2;
if(h1*2<n-3)
h2++;
W=1;
W+=n/6;
for(int i=0;i<n;i++)
{
if(i==0)
{
for(int j=0;j<W;j++)
{
cout<<" ";
}
for(int j=0;j<h2;j++)
{
cout<<c;
}
cout<<endl;
}
else if(i>=1&&i<h1+1)
{
for(int j=0;j<W;j++)
cout<<c;
for(int j=0;j<h2;j++)
cout<<" ";
for(int j=0;j<W;j++)
{
cout<<c;
}
cout<<endl;
}
else if(h1+1==i)
{
for(int j=0;j<W;j++)
{
cout<<" ";
}
for(int j=0;j<h2;j++)
cout<<c;
cout<<endl;
}
else if(i>h1+1&&i<n-1)
{
for(int j=0;j<W;j++)
cout<<c;
for(int j=0;j<h2;j++)
cout<<" ";
for(int j=0;j<W;j++)
cout<<c;
cout<<endl;
}
else if(i==n-1)
{
for(int j=0;j<W;j++)
{
cout<<" ";
}
for(int j=0;j<h2;j++)
cout<<c;
cout<<endl;
}
}
}
return 0;
}
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
char c;
int n;
int W;
int h1,h2;
while(cin>>c>>n)
{
h1=h2=(n-3)/2;
if(h1*2<n-3)
h2++;
W=1;
W+=n/6;
for(int i=0;i<n;i++)
{
if(i==0)
{
for(int j=0;j<W;j++)
{
cout<<" ";
}
for(int j=0;j<h2;j++)
{
cout<<c;
}
cout<<endl;
}
else if(i>=1&&i<h1+1)
{
for(int j=0;j<W;j++)
cout<<c;
for(int j=0;j<h2;j++)
cout<<" ";
for(int j=0;j<W;j++)
{
cout<<c;
}
cout<<endl;
}
else if(h1+1==i)
{
for(int j=0;j<W;j++)
{
cout<<" ";
}
for(int j=0;j<h2;j++)
cout<<c;
cout<<endl;
}
else if(i>h1+1&&i<n-1)
{
for(int j=0;j<W;j++)
cout<<c;
for(int j=0;j<h2;j++)
cout<<" ";
for(int j=0;j<W;j++)
cout<<c;
cout<<endl;
}
else if(i==n-1)
{
for(int j=0;j<W;j++)
{
cout<<" ";
}
for(int j=0;j<h2;j++)
cout<<c;
cout<<endl;
}
}
}
return 0;
}