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.
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).
——摘自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;
}