Result | TIME Limit | MEMORY Limit | Run Times | AC Times | JUDGE |
---|---|---|---|---|---|
3s | 8192K | 2251 | 642 | Standard |
The input file will be terminated by a line containing two zeros. This line should not be processed.
Output a blank line after each number. (You will find a sample of each digit in the sample output.)
2 12345 3 67890 0 0
-- -- -- | | | | | | | | | | | | -- -- -- -- | | | | | | | | | | -- -- -- --- --- --- --- --- | | | | | | | | | | | | | | | | | | | | | | | | --- --- --- | | | | | | | | | | | | | | | | | | | | | | | | --- --- --- ---
Submit / Problem List / Status / Discuss
想了半天回,实在是没有能减少代码量的想法。我的想法是暴力模拟,直接把0-9全写出来,一个个处理。但是代码几百行几百行。
参考了大牛代码。
直接贴上,过些日子再想想。
1 #include <iostream>
2 #include <string>
3
4 using namespace std;
5
6 char code[5][31]=
7 {
8 {" - - - - - - - - "},
9 {"| | | | || || | || || |"},
10 {" - - - - - - - "},
11 {"| | || | | || | || | |"},
12 {" - - - - - - - "},
13 };
14
15 void print(int n, string& s,int i)
16 {
17 int length = s.length();
18 int j, k, m;
19 for(j =0; j < length; j++)
20 {
21 /* 找到数字j的下标 */
22 m =(s[j]-'0')*3;
23
24 cout<< code[i][m];
25 /* 关键笔画打印n次 */
26 for(k =0; k < n; k++)
27 {
28 cout<< code[i][m +1];
29 }
30 cout<< code[i][m +2];
31
32 /* 每2个数字间加一个空格 */
33 if(j != length -1)cout<<" ";
34 }
35 cout<< endl;
36 }
37
38 int main()
39 {
40 int i, j, n;
41 string s;
42 while(1)
43 {
44 cin >> n;
45 if(n ==0)break;
46 cin >> s;
47 for(i =0; i <5; i++)
48 {
49 if(i %2)
50 {
51 /* 纵行要打印n次 */
52 for(j =0; j < n; j++)
53 {
54 print(n, s, i);
55 }
56 }
57 else
58 {
59 print(n, s, i);
60 }
61 }
62 cout<< endl;
63 }
64 //system("pause");
65 return0;
66 }
67