HDU 6077 17多校4 Time To Get Up 水题

Problem Description
Little Q's clock is alarming! It's time to get up now! However, after reading the time on the clock, Little Q lies down and starts sleeping again. Well, he has 

Your job is to help Little Q read the time shown on his clock.
 
Input
The first line of the input contains an integer 21 ASCII image of the clock screen.

All digit segments are represented by two characters, and each colon segment is represented by one character. The character ''X'' indicates a segment that is on while ''.'' indicates anything else. See the sample input for details.
 
Output
For each test case, print a single line containing a string ), denoting the time shown on the clock.
 
Sample Input
1
.XX...XX.....XX...XX.
X..X....X......X.X..X
X..X....X.X....X.X..X
......XX.....XX...XX.
X..X.X....X....X.X..X
X..X.X.........X.X..X
.XX...XX.....XX...XX.
 
Sample Output
02:38

题意:把字符串翻译成时间。

题解:直接利用他们的区别判断即可。

 1 #include <iostream>
 2 #include<cstdio>
 3 #include<algorithm>
 4 #include<queue>
 5 #include<map>
 6 #include<vector>
 7 #include<cmath>
 8 #include<cstring>
 9 using namespace std;
10 
11 char time[7+1][21+1];
12 int check(int i)
13 {
14     int j;
15     if(time[6][i]=='X')
16     {
17         if(time[4][i+1]=='.')
18             return 0;
19         else if(time[2][i]=='.')
20             return 2;
21         else if(time[2][i+3]=='.')
22             return 6;
23         else
24             return 8;
25     }
26     else
27     {
28         if(time[2][i]=='X')
29         {
30             if(time[1][i+1]=='X')
31             {
32                 if(time[2][i+3]=='X')
33                     return 9;
34                 else
35                     return 5;
36             }
37             else
38                 return 4;
39         }
40         else
41         {
42             if(time[4][i+1]=='.')
43             {
44                 if(time[1][i+1]=='X')
45                     return 7;
46                 else
47                     return 1;
48             }
49             else
50                 return 3;
51         }
52     }
53 }
54 
55 int main()
56 {
57     int a,b,c,d;
58     int T;
59     scanf("%d",&T);
60     while(T--)
61     {
62         for(int i=1;i<=7;i++)
63             for(int j=1;j<=21;j++)
64                 cin>>time[i][j];
65         a=check(1);
66         b=check(6);
67         c=check(13);
68         d=check(18);
69         printf("%d%d:%d%d
",a,b,c,d);
70     }
71     return 0;
72 }