Output related problem. I use a predefined bitmap of all the numbers and enlarge them when displaying.
Code:
- /*************************************************************************
- * Copyright (C) 2008 by liukaipeng *
- * liukaipeng at gmail dot com *
- *************************************************************************/
- /* @JUDGE_ID 00000 706 C "LC-Display" */
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include <strings.h>
- int bitmap_row(int r, int s)
- {
- if (r == 0)
- return 0;
- else if (r == s+1)
- return 2;
- else if (r == 2*(s+1))
- return 4;
- else if (r < s+1)
- return 1;
- else
- return 3;
- }
- int bitmap_col(int c, int s)
- {
- if (c == 0)
- return 0;
- else if (c == s+1)
- return 2;
- else
- return 1;
- }
- int main(int argc, char *argv[])
- {
- #ifndef ONLINE_JUDGE
- char in[256];
- char out[256];
- strcpy(in, argv[0]);
- strcat(in, ".in");
- freopen(in, "r", stdin);
- strcpy(out, argv[0]);
- strcat(out, ".out");
- freopen(out, "w", stdout);
- #endif
- char bitmap[5][30] = {
- " - - - - - - - - ",
- "| | | | || || | || || |",
- " - - - - - - - ",
- "| | || | | || | || | |",
- " - - - - - - - ",
- };
- int s, l, n, i, j, row, col;
- char buf[10];
- for (scanf("%d %s/n", &s, buf); s != 0; scanf("%d %s/n", &s, buf)) {
- l = strlen(buf);
- for (i = 0; i < 2*s+3; ++i) {
- row = bitmap_row(i, s);
- for (j = 0; j < (s+2)*l; ++j) {
- if (j > 0 && j % (s+2) == 0)
- putchar(' ');
- n = buf[j/(s+2)] - '0';
- col = bitmap_col(j%(s+2), s);
- col += 3*n;
- putchar(bitmap[row][col]);
- }
- putchar('/n');
- }
- putchar('/n');
- }
- return 0;
- }