Problem Description
Digital LC-display is widely used in many different fields such as electronic calculator, electronic watch, digital instruments, etc. A simulated example of the numbers represented by digital LC-display device is shown as follows:
Each number represented by LC-display above is composed of s "-" signs for the horizontal segments and s "|" signs for the vertical ones, and each number exactly occupies s+2 columns and 2s+3 rows. Your task is to change the size of the original numbers by changing "s" — the number of signs.
![](https://i-blog.csdnimg.cn/blog_migrate/89f0f53c76afe5bed833e316dba94101.jpeg)
Each number represented by LC-display above is composed of s "-" signs for the horizontal segments and s "|" signs for the vertical ones, and each number exactly occupies s+2 columns and 2s+3 rows. Your task is to change the size of the original numbers by changing "s" — the number of signs.
Input
The first line of input contains a number t, which means there are t cases of the test data.
The input contains several lines, 2s + 4 for each number to be displayed. The first line of each case contains two integer s and t (1 <= s, t <= 9), where s is the original size of the numbers and t is the target size of numbers that you should output. The following 2s + 3 lines show the original number n (the digit of n will not exceed 9) you should deal with. Each digit of n will be separated by an empty column (except for the last digit).
The input contains several lines, 2s + 4 for each number to be displayed. The first line of each case contains two integer s and t (1 <= s, t <= 9), where s is the original size of the numbers and t is the target size of numbers that you should output. The following 2s + 3 lines show the original number n (the digit of n will not exceed 9) you should deal with. Each digit of n will be separated by an empty column (except for the last digit).
Output
For each test case, output the case number and then output the target number according to the input. Output a blank line after each case.
——摘自HDOJ 3575(测试数据不好显示)
这道题题目不难!看了后题目大家都会有想法,是的,我承认不难,但想起自己当初(也才昨天而已)实现的时候真是太痛苦了!都怪自己审题不仔细,忽略了数据的大小。所以一开始时,存储输入数据的数组就只开了100*100, 呃。。写完后本地测试数据轻松过,但提交总是WA!这种情况是很郁闷的!当时改了一下午,空格换行之类的细节想得都快晕了!
到后来是心灰意冷,真没辙了。没办法了,就很无聊的把数据改大了点,草,竟奇迹般地过了。。Accept!!!有木有搞错啊……盼望了一下午啊!可还是高兴不起来,当时真的是哭笑不得。。
注意审题啊,切记……切记……
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
int m,n;
char digit[1500][1500];
void f(int row)
{
int i,j,k;
int len = strlen(digit[row]);
for(i=0; i*(m+2)+i-1<len; i++)
{
if(i != 0)
printf(" ");
printf(" ");
for(j=0; j<n; j++)
if(digit[row][(m+2)*i+i+1] == '-')
printf("-");
else printf(" ");
printf(" ");
}
printf("\n");
}
void g(int row)
{
int i,j,k;
int len = strlen(digit[row]);
for(i=0; i*(m+2)+i-1<len; i++)
{
if(i != 0)
printf(" ");
printf("%c", digit[row][(m+2)*i+i]);
for(j=0; j<n; j++)
printf(" ");
printf("%c", digit[row][i*(m+2)+i+m+1]);
}
printf("\n");
}
int main()
{
int cases, t;
int i,j,k;
scanf("%d", &cases);
t = 1;
while(t <= cases)
{
scanf("%d %d", &m, &n);
getchar();
for(i=0; i<2*m+3; i++)
gets(digit[i]);
printf("Case %d:\n", t);
f(0);
for(i=0; i<n; i++)
g(1);
f(m+1);
for(i=0; i<n; i++)
g(m+2);
f(2*m+2);
t++;
//if(t != cases)
printf("\n");
}
return 0;
}