杭电 Time To Get Up

26 篇文章 1 订阅
17 篇文章 0 订阅
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 5 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.
 

Input
The first line of the input contains an integer T(1T1440) , 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.
 

Output
For each test case, print a single line containing a string t in the format of HH:MM , where t(00:00t23:59) , 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

题意:输入7 X 21的字符串,输出时间

分析:直接模拟啊,0-20列,第4 9 10 11 16 列都不是有效的列,剩下的16列表示4个数,并且都是连续的,每一个7 X 4都判断一次,看看是什么数,输出即可

AC代码如下:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
using namespace std;

char a[10][25];
char ch[7][4];

int fun(char c[7][4])//利用数形状的差距直接判断
{
    for(int i=0;i<7;i++)
        for(int j=0;j<4;j++)
    {
        if(c[3][1]=='X' && c[3][2]=='X')
        {
            if(c[0][1]=='.' && c[0][2]=='.')
                return 4;
            if(c[4][0]=='X' && c[5][0]=='X')
            {
                if(c[1][0]=='.' && c[2][0]=='.')
                    return 2;
                if(c[1][3]=='X' && c[2][3]=='X')
                    return 8;
                return 6;
            }
            else
            {
                if(c[1][3]=='.' && c[2][3]=='.')
                    return 5;
                if(c[1][0]=='.' && c[2][0]=='.')
                    return 3;
                return 9;
            }
        }
        else if(c[3][1]=='.' && c[3][2]=='.')
        {
            if(c[1][0]=='X' && c[2][0]=='X')
                return 0;
            if(c[0][1]=='X' && c[0][2]=='X')
                return 7;
            return 1;
        }
    }
    return -1;
}

int main()
{
    int t;
    cin>>t;
    getchar();
    while(t--)
    {
        for(int i=0;i<7;i++)
            scanf("%s",a[i]);
        int num=0;
        int coun=0;
        for(int j=0;j<21;j++)
        {
            if(j==4 || j==9 || j==10 || j==11 || j==16)
            {
                continue;
            }
            else
            {
                num++;
            }
            if(num%4==0)//累计四行做一次判断
            {
                for(int i=0;i<7;i++)
                {
                    for(int k=j-3,s=0;k<=j;k++,s++)
                    {
                        ch[i][s]=a[i][k];
                    }
                }
                cout<<fun(ch);
                coun++;
                if(coun==2) cout<<":";
            }
        }
        cout<<endl;
    }
    return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值