hdu 6993 / 2021“MINIEYE杯”中国大学生算法设计超级联赛(4)1009 License Plate Recognition

https://acm.hdu.edu.cn/showproblem.php?pid=6993

题意:

识别7位车牌号的每个字符出现的位置

认真读题认真读题,题目不会随便说废话!

下载题目给的材料,不会随便给没用的材料!

从下载的点阵来看英文和数字都是连着的,而输入说只有第一个可能是数字

所以把后6个都找出来

第一个的左端点是从第1列开始第一次出现#的列

右端点从第2个字符左端点之前找第一次出现#的列

#include<bits/stdc++.h>

using namespace std;

char s[31][102];

int ans[8][2];

bool check(int x)
{
    for(int i=1;i<=30;++i)
        if(s[i][x]=='#') return true;
    return false;
}

int main()
{
    int T,last,id;
    scanf("%d",&T);
    for(int t=1;t<=T;++t)
    {
        printf("Case #%d:
",t);
        for(int i=1;i<=30;++i) scanf("%s",s[i]+1);
        last=0;
        int i;
        for(i=1;i<=100;++i) 
            if(check(i)) 
            {
                ans[1][0]=i;
                break;
            }
        last=0;
        id=7;
        for(i=100;;--i)
            if(check(i))
            {
                if(!last) ans[id][1]=i;
                last=1;
            }
            else if(last) 
            {
                ans[id--][0]=i+1;
                last=0;
                if(id==1) break;
            }
        for(--i;;--i)
            if(check(i))  
            {
                ans[1][1]=i;
                break;
            }
        for(int i=1;i<=7;++i) printf("%d %d
",ans[i][0],ans[i][1]);
    }
}
作者:xxy
本文版权归作者和博客园共有,转载请用链接,请勿原文转载,Thanks♪(・ω・)ノ。
原文地址:https://www.cnblogs.com/TheRoadToTheGold/p/15133739.html