HDU - 6077 Time To Get Up
问题描述:
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 alarms, and it's just the first one, he can continue sleeping for a while.Little Q’s clock uses a standard 7-segment LCD display for all digits, plus two small segments for the ‘’:’’, and shows all times in a 24-hour format. The ‘’:’’ segments are on at all times.
这里有一张图片
Your job is to help Little Q read the time shown on his clock.
输入说明:
The first line of the input contains an integer T(1≤T≤1440), denoting the number of test cases.
In each test case, there is an 7×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.
输出说明:
For each test case, print a single line containing a string t in the format of HH:MM, where t(00:00≤t≤23:59), denoting the time shown on the clock.
思路:
一开始做这道题的时候是很懵逼的,完全没发现时间怎么表示,一堆.和x,还在想有什么含义,仔细观察了那张图发现是根据图中10个数码的不同形状打表,把10种情况列举出来,然后直接和输入进行比较,最后得到时间。每个数字都是由一个4*7的.×阵组成的,直接写一个这样的矩阵也是可以的,我这里结合不同数字在不同点的情况进行了判断总之有点麻烦的一道题,但是思路很清楚。
AC代码:
#include<bits/stdc++.h>
using namespace std;
char a[12][26];
int T;
int main()
{
cin>>T;
while(T--)
{
for(int i=0; i<7; i++)
{
for(int j=0; j<21; j++)
{
cin>>a[i][j];
}
}
int d1,d2,d3,d4;
if(a[0][1]=='.'&&a[0][2]=='.')
{
if(a[1][0]=='X') d1=4;
else d1=1;
}
else if(a[1][0]=='.'&&a[4][0]=='.')
{
if(a[3][1]=='X') d1=3;
else d1=7;
}
else if(a[3][1]=='.'&&a[3][2]=='.')
{
d1=0;
}
else if(a[4][3]=='.'&&a[5][3]=='.')
{
d1=2;
}
else if(a[1][3]=='.'&&a[2][3]=='.')
{
if(a[4][0]=='.') d1=5;
else d1=6;
}
else if(a[4][0]=='.'&&a[5][0]=='.')
{
d1=9;
}
else d1=8;
if(a[0][1+5]=='.'&&a[0][2+5]=='.')
{
if(a[1][0+5]=='X') d2=4;
else d2=1;
}
else if(a[1][0+5]=='.'&&a[4][0+5]=='.')
{
if(a[3][1+5]=='X') d2=3;
else d2=7;
}
else if(a[3][1+5]=='.'&&a[3][2+5]=='.')
{
d2=0;
}
else if(a[4][3+5]=='.'&&a[5][3+5]=='.')
{
d2=2;
}
else if(a[1][3+5]=='.'&&a[2][3+5]=='.')
{
if(a[4][0+5]=='.') d2=5;
else d2=6;
}
else if(a[4][0+5]=='.'&&a[5][0+5]=='.')
{
d2=9;
}
else d2=8;
if(a[0][1+12]=='.'&&a[0][2+12]=='.')
{
if(a[1][0+12]=='X') d3=4;
else d3=1;
}
else if(a[1][0+12]=='.'&&a[4][0+12]=='.')
{
if(a[3][1+12]=='X') d3=3;
else d3=7;
}
else if(a[3][1+12]=='.'&&a[3][2+12]=='.')
{
d3=0;
}
else if(a[4][3+12]=='.'&&a[5][3+12]=='.')
{
d3=2;
}
else if(a[1][3+12]=='.'&&a[2][3+12]=='.')
{
if(a[4][0+12]=='.') d3=5;
else d3=6;
}
else if(a[4][0+12]=='.'&&a[5][0+12]=='.')
{
d3=9;
}
else d3=8;
if(a[0][18]=='.'&&a[0][19]=='.')
{
if(a[1][17]=='X') d4=4;
else d4=1;
}
else if(a[1][17]=='.'&&a[4][17]=='.')
{
if(a[3][18]=='X') d4=3;
else d4=7;
}
else if(a[3][18]=='.'&&a[3][19]=='.')
{
d4=0;
}
else if(a[4][20]=='.'&&a[5][20]=='.')
{
d4=2;
}
else if(a[1][20]=='.'&&a[2][20]=='.')
{
if(a[4][17]=='.') d4=5;
else d4=6;
}
else if(a[4][17]=='.'&&a[5][17]=='.')
{
d4=9;
}
else d4=8;
cout<<d1<<d2<<":"<<d3<<d4<<endl;
}
return 0;
}