uva :: Programming Challenges :: Chapter 1 :: 706 - LCD Display
1
/*
2 * File: 706.cpp
3 * Author: GongZhi
4 * Problem: http://uva.onlinejudge.org/index.php?option=com_onlinejudge &Itemid=8&category=29&page=show_problem&problem=647
5 * Created on 2009年7月25日, 下午10:08
6 */
7
8 #include < stdlib.h >
9 #include < string .h >
10 #include < iostream >
11 #include < string >
12 #include < vector >
13 #include < map >
14 #include < queue >
15 using namespace std;
16
17 /*
18 *
19 */
20
21 // 下面为0~9字符表示
22 int P[ 10 ][ 7 ] = {
23 { 1 , 1 , 1 , 0 , 1 , 1 , 1 },
24 { 0 , 0 , 1 , 0 , 0 , 1 , 0 },
25 { 1 , 0 , 1 , 1 , 1 , 0 , 1 },
26 { 1 , 0 , 1 , 1 , 0 , 1 , 1 },
27 { 0 , 1 , 1 , 1 , 0 , 1 , 0 },
28 { 1 , 1 , 0 , 1 , 0 , 1 , 1 },
29 { 1 , 1 , 0 , 1 , 1 , 1 , 1 },
30 { 1 , 0 , 1 , 0 , 0 , 1 , 0 },
31 { 1 , 1 , 1 , 1 , 1 , 1 , 1 },
32 { 1 , 1 , 1 , 1 , 0 , 1 , 1 }
33 };
34
35 int main() {
36 int s, i, j, l, k;
37 char n[ 100 ];
38 while (scanf( " %d%s " , & s, n), s) {
39 l = strlen(n);
40 for (i = 0 ; i < l; i ++ )n[i] -= ' 0 ' ;
41 // 0
42 for (i = 0 ; i < l; i ++ ) {
43 if (i != 0 )printf( " " );
44 printf( " " );
45 for (j = 0 ; j < s; j ++ )
46 if (P[n[i]][ 0 ])printf( " - " );
47 else printf( " " );
48 printf( " " );
49 }
50 printf( " \n " );
51 // 1&2
52 for (k = 0 ; k < s; k ++ ) {
53 for (i = 0 ; i < l; i ++ ) {
54 if (i != 0 )printf( " " );
55 if (P[n[i]][ 1 ])printf( " | " );
56 else printf( " " );
57 for (j = 0 ; j < s; j ++ )printf( " " );
58 if (P[n[i]][ 2 ])printf( " | " );
59 else printf( " " );
60 }
61 printf( " \n " );
62 }
63 // 3
64 for (i = 0 ; i < l; i ++ ) {
65 if (i != 0 )printf( " " );
66 printf( " " );
67 for (j = 0 ; j < s; j ++ )
68 if (P[n[i]][ 3 ])printf( " - " );
69 else printf( " " );
70 printf( " " );
71 }
72 printf( " \n " );
73 // 4&5
74 for (k = 0 ; k < s; k ++ ) {
75 for (i = 0 ; i < l; i ++ ) {
76 if (i != 0 )printf( " " );
77 if (P[n[i]][ 4 ])printf( " | " );
78 else printf( " " );
79 for (j = 0 ; j < s; j ++ )printf( " " );
80 if (P[n[i]][ 5 ])printf( " | " );
81 else printf( " " );
82 }
83 printf( " \n " );
84 }
85 // 6
86 for (i = 0 ; i < l; i ++ ) {
87 if (i != 0 )printf( " " );
88 printf( " " );
89 for (j = 0 ; j < s; j ++ )
90 if (P[n[i]][ 6 ])printf( " - " );
91 else printf( " " );
92 printf( " " );
93 }
94 printf( " \n " );
95 // 因为没加下面这个居然wa了一次
96 printf( " \n " );
97 }
98
99 return 0 ;
100 }
101
102
2 * File: 706.cpp
3 * Author: GongZhi
4 * Problem: http://uva.onlinejudge.org/index.php?option=com_onlinejudge &Itemid=8&category=29&page=show_problem&problem=647
5 * Created on 2009年7月25日, 下午10:08
6 */
7
8 #include < stdlib.h >
9 #include < string .h >
10 #include < iostream >
11 #include < string >
12 #include < vector >
13 #include < map >
14 #include < queue >
15 using namespace std;
16
17 /*
18 *
19 */
20
21 // 下面为0~9字符表示
22 int P[ 10 ][ 7 ] = {
23 { 1 , 1 , 1 , 0 , 1 , 1 , 1 },
24 { 0 , 0 , 1 , 0 , 0 , 1 , 0 },
25 { 1 , 0 , 1 , 1 , 1 , 0 , 1 },
26 { 1 , 0 , 1 , 1 , 0 , 1 , 1 },
27 { 0 , 1 , 1 , 1 , 0 , 1 , 0 },
28 { 1 , 1 , 0 , 1 , 0 , 1 , 1 },
29 { 1 , 1 , 0 , 1 , 1 , 1 , 1 },
30 { 1 , 0 , 1 , 0 , 0 , 1 , 0 },
31 { 1 , 1 , 1 , 1 , 1 , 1 , 1 },
32 { 1 , 1 , 1 , 1 , 0 , 1 , 1 }
33 };
34
35 int main() {
36 int s, i, j, l, k;
37 char n[ 100 ];
38 while (scanf( " %d%s " , & s, n), s) {
39 l = strlen(n);
40 for (i = 0 ; i < l; i ++ )n[i] -= ' 0 ' ;
41 // 0
42 for (i = 0 ; i < l; i ++ ) {
43 if (i != 0 )printf( " " );
44 printf( " " );
45 for (j = 0 ; j < s; j ++ )
46 if (P[n[i]][ 0 ])printf( " - " );
47 else printf( " " );
48 printf( " " );
49 }
50 printf( " \n " );
51 // 1&2
52 for (k = 0 ; k < s; k ++ ) {
53 for (i = 0 ; i < l; i ++ ) {
54 if (i != 0 )printf( " " );
55 if (P[n[i]][ 1 ])printf( " | " );
56 else printf( " " );
57 for (j = 0 ; j < s; j ++ )printf( " " );
58 if (P[n[i]][ 2 ])printf( " | " );
59 else printf( " " );
60 }
61 printf( " \n " );
62 }
63 // 3
64 for (i = 0 ; i < l; i ++ ) {
65 if (i != 0 )printf( " " );
66 printf( " " );
67 for (j = 0 ; j < s; j ++ )
68 if (P[n[i]][ 3 ])printf( " - " );
69 else printf( " " );
70 printf( " " );
71 }
72 printf( " \n " );
73 // 4&5
74 for (k = 0 ; k < s; k ++ ) {
75 for (i = 0 ; i < l; i ++ ) {
76 if (i != 0 )printf( " " );
77 if (P[n[i]][ 4 ])printf( " | " );
78 else printf( " " );
79 for (j = 0 ; j < s; j ++ )printf( " " );
80 if (P[n[i]][ 5 ])printf( " | " );
81 else printf( " " );
82 }
83 printf( " \n " );
84 }
85 // 6
86 for (i = 0 ; i < l; i ++ ) {
87 if (i != 0 )printf( " " );
88 printf( " " );
89 for (j = 0 ; j < s; j ++ )
90 if (P[n[i]][ 6 ])printf( " - " );
91 else printf( " " );
92 printf( " " );
93 }
94 printf( " \n " );
95 // 因为没加下面这个居然wa了一次
96 printf( " \n " );
97 }
98
99 return 0 ;
100 }
101
102