D Digit Size

Source: Internet
Author: User

Problem DescriptionDigital LC-display is widely used in your 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 abve 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 2 s + 3 rows. your task is to change the size of the original numbers
Changing "s"-the number of signs.

InputThe first line of input contains a number t, which means there are t cases of the test data.
The input contains several lines, 2 s + 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 2 s + 3 lines show the original number n (the digit of n will not exceed 9) you shoshould deal. each digit of n will be separated by an empty column (blocks t for the last digit ).

OutputFor each test case, output the case number and then output the target number according to the input. Output a blank line after each case.

 

-- From HDOJ 3575 (poor display of test data)

This question is not difficult! After reading the questions, everyone will have an idea. Yes, I admit it is not difficult, but it is so painful to remember that I realized it yesterday! I blame myself for failing to examine the questions carefully and ignore the data size. So at the beginning, the array that stores input data only opened 100*100 .. The local test data is easy to use after writing, but the submission is always WA! This situation is depressing! At that time, I changed it for one afternoon and thought about details like space wrapping!

It was disheartened later. No way, it's boring to make the data bigger, grass, it's a miracle .. Accept !!! Something wrong ...... Hope for an afternoon! But I was still not happy. At that time, I was really crying and laughing ..

Pay attention to questions. Remember ...... Remember ......

#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;    }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.