#include <stdio.h> void display(int n, int t, int type) { int i, j; switch (type) { case 1: putchar(' '); for (i = 0; i < t; i++) printf("%c", (n == 1 || n == 4) ? ' ' : '-'); putchar(' '); break; case 2: if (n == 1 || n == 2 || n == 3 || n == 7) putchar(' '); else putchar('|'); for (i = 0; i < t; i++) putchar(' '); printf("%c", (n == 5 || n == 6) ? ' ' : '|'); break; case 3: putchar(' '); for (i = 0; i < t; i++) printf("%c", (n == 1 || n == 7 || n == 0) ? ' ' : '-'); putchar(' '); break; case 4: if (n == 1 || n == 3 || n == 4 || n == 5 || n == 7 || n == 9) putchar(' '); else putchar('|'); for (i = 0; i < t; i++) putchar(' '); printf("%c", (n == 2) ? ' ' : '|'); break; case 5: putchar(' '); for (i = 0; i < t; i++) printf("%c", (n == 1 || n == 4 || n == 7) ? ' ' : '-'); putchar(' '); break; } } int main() { int i, j, k, n, times, type; while (scanf("%d %d", ×, &n) && times || n) { char num[20]; sprintf(num, "%d", n); for (type = 1; type <= 5; type++) { if (type == 2 || type == 4) k = times; else k = 1; while (k--) { for (i = 0; num[i] != '\0'; i++) { if (i) putchar(' '); display(num[i] - '0', times, type); } puts(""); } } puts(""); } return 0; }
Hello, I am a CS student from Taiwan.
I am learing English and Programming.
I'll save source code of some problems or small programs without comments in this blog.
I would recommend you not to read solution from others before you solved the problem.
(這邊專門存放沒有任何註解的小程式/OJ題目程式碼)
2012年8月20日
UVa 706 - LCD Display
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言