[HDOJ3575]Digit Size

水题~

View Code
1 #include <cstdio>
2 #include <cstring>
3
4  using namespace std;
5
6  const int MAXL = 10000;
7 const int SIZE = 32;
8
9 char input[SIZE][MAXL];
10 char output[SIZE][MAXL];
11
12 int main()
13 {
14 int s;
15 int t;
16 int cas;
17
18 scanf("%d",&cas);
19
20 for (int cc = 1;cc <= cas;cc++)
21 {
22 memset(output,' ',sizeof(output));
23
24 scanf("%d %d",&s,&t);
25 getchar();
26
27 for (int i = 0;i < 2 * s + 3;i++)
28 gets(input[i]);
29
30 int len = strlen(input[0]);
31 int num = (len + 1) / (s + 3);
32
33 for (int i = 0;i < len;i++)
34 if (input[0][i] == '-')
35 {
36 int idx = i / (s + 3) * (t + 3) + 1;
37 for (int j = 0;j < t;j++)
38 output[0][idx++] = '-';
39 while (input[0][i] == '-' && i < len) i++;
40 }
41
42 for (int i = 0;i < len;i++)
43 if (input[1][i] == '|')
44 {
45 int idx = i / (s + 3) * (t + 3);
46 if (i % (s + 3) == s + 1) idx += t + 1;
47 for (int j = 1;j <= t;j++)
48 output[j][idx] = '|';
49 }
50
51 for (int i = 0;i < len;i++)
52 if (input[s+1][i] == '-')
53 {
54 int idx = i / (s + 3) * (t + 3) + 1;
55 for (int j = 0;j < t;j++)
56 output[t+1][idx++] = '-';
57 while (input[s+1][i] == '-' && i < len) i++;
58 }
59
60 for (int i = 0;i < len;i++)
61 if (input[s+2][i] == '|')
62 {
63 int idx = i / (s + 3) * (t + 3);
64 if (i % (s + 3) == s + 1) idx += t + 1;
65 for (int j = t + 2;j < t + 2 + t;j++)
66 output[j][idx] = '|';
67 }
68
69 for (int i = 0;i < len;i++)
70 if (input[2 * s + 2][i] == '-')
71 {
72 int idx = i / (s + 3) * (t + 3) + 1;
73 for (int j = 0;j < t;j++)
74 output[2 * t + 2][idx++] = '-';
75 while (input[2 * s + 2][i] == '-' && i < len) i++;
76 }
77
78 printf("Case %d:\n",cc);
79
80 for (int i = 0;i < 2 * t + 3;i++)
81 {
82 for (int j = 0;j < (t + 3) * num - 1;j++)
83 printf("%c",output[i][j]);
84 printf("\n");
85 }
86
87 printf("\n");
88 }
89 return 0;
90 }
原文地址:https://www.cnblogs.com/debugcool/p/HDOJ3575.html