Title Description
谁画8画的好,画的快,今后就发的快,学业发达,事业发达,祝大家发,发,发.
Input
输入的第一行为一个整数N,表示后面有N组数据.
每组数据中有一个字符和一个整数,字符表示画笔,整数(>=5)表示高度.
Output
画横线总是一个字符粗,竖线随着总高度每增长6而增加1个字符宽.当总高度从5增加到6时,其竖线宽度从1增长到2.下圈高度不小于上圈高度,但应尽量接近上圈高度,且下圈的内径呈正方形.
每画一个"8"应空一行,但最前和最后都无空行.
Sample Input
2
A 7
B 8
Sample Output
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 <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
int main()
{
int n;
char m;
int t;
scanf("%d",&t);
for(int l =1; l<=t; l++)
{
getchar();
scanf("%c%d",&m,&n);
///第一个:计算空格的长度
int k = (n - 5 +5)/6 + 1;
///第三个:计算上面的长度
int s = (n-3)/2;
///第二个:计算行的长度
int h = k*2 + (n-3 + 1)/2;
///打印第一行的数据
for(int i=1; i<=k; i++)
printf(" ");
for(int i=1; i<=h - 2*k; i++)
printf("%c",m);
printf("\n");
///上面数据的输出
for(int i=1; i<=s; i++)
{
for(int j=1; j<=k; j++)
printf("%c",m);
for(int j=1; j<=h - 2*k; j++)
printf(" ");
for(int j=1; j<=k; j++)
printf("%c",m);
printf("\n");
}
///中间的数据
for(int i=1; i<=k; i++)
printf(" ");
for(int i=1; i<=h - 2*k; i++)
printf("%c",m);
printf("\n");
///下面数据长度
for(int i=1; i<=n-s-3; i++)
{
for(int j=1; j<=k; j++)
printf("%c",m);
for(int j=1; j<=h - 2*k; j++)
printf(" ");
for(int j=1; j<=k; j++)
printf("%c",m);
printf("\n");
}
///最后一行的数据
for(int i=1; i<=k; i++)
printf(" ");
for(int i=1; i<=h - 2*k; i++)
printf("%c",m);
printf("\n");
if(t!=l)
printf("\n");
}
return 0;
}