2017 Multi-University Training Contest

来源:互联网 发布:波士顿矩阵分析案例题 编辑:程序博客网 时间:2024/06/07 11:29

题目链接

输入二维字符数组,让判断上面显示的时间。

观察数字特征:

如果上面没有横,这样的数字只有1,4,很容易辨别1,4的特征,剩余的数字为0,2,3,5,6,7,8,9

然后看一判断中间没有横的数字,这样的数字只有0,7,然后可以再辨别这两个数的特征,剩余数字2,3,5,6,8,9

然后发现2这个数字,没有右下角那一竖,所以可以把2辨别出来,剩余3,5,6,8,9

然后剩余数字数,只有3左上角那一竖不存在,所以可以把3辨别出来,剩余5,6,8,9

而5,6,都没有右上角那一竖,可以再把5,6辨别出来。

剩余8,9很好辨别。


#include <iostream>#include <stdio.h>using namespace std;char g[10][30];int judge(int num)  ///判断那个数字{    int L;    if(num == 1) {L = 0;}    if(num == 2) {L = 5;}    if(num == 3) {L = 12;}    if(num == 4) {L = 17;}    if(g[1][L+1] != 'X')  ///这样的数字有1,和4    {        if(g[2][L] == 'X') return 4;        else return 1;    }    else if(g[4][L+1] != 'X')  ///这样的数字有0和7    {        if(g[2][L] == 'X') return 0;        else return 7;    }    else if(g[5][L+3] != 'X')    {        return 2;    }    else if(g[2][L] != 'X')    {        return 3;    }    else if(g[2][L+3] != 'X')  ///这样的数有5,6    {        if(g[5][L] == 'X') return 6;        else return 5;    }    else    {        if(g[5][L] == 'X') return 8;        else return 9;    }}int main(){    int t;    scanf("%d",&t);    while(t--)    {        for(int i = 1; i <= 7; i++)        {            scanf("%s",g[i]);        }        int time1 = judge(1);        int time2 = judge(2);        int time3 = judge(3);        int time4 = judge(4);        printf("%d%d:%d%d\n",time1,time2,time3,time4);    }    return 0;}




原创粉丝点击