• 暑假练习赛 007 C


    C - OCR

    Description

    standard input/output
    Statements

    Optical Character Recognition (OCR) is one of the most famous fields of Artificial Intelligence. The main purpose of OCR is to recognize printed text (or handwriting) and convert it to the machine encoded-text. You may have seen similar applications in your smartphone: you use your camera to take a photo that contains text, then, the text is translated or saved in PDF, for example. In this problem we deal with a very limited case of OCR. You have a scanned character which is either ‘0’ (number zero) or ‘8’ (number eight) and you have to decide what number it is. The input will be an image that contains exactly one character (It is guaranteed that this character is either ‘0’ or ‘8’). The image has 2 colors: white (represented with dot ‘.’) and black (represented with asterisk ‘*’). For simplicity, the borders of the image are always white. It’s also guaranteed that black lines inside the image are either vertical or horizontal. So you may safely assume that the shapes of ‘0’ and ‘8’ inside the image are the same as their shapes in digital clocks. However, they might be stretched or not positioned in the center of the image.

    Input

    The first line will be the number of test cases T (T<100). Each test case starts with two positive integers (n,m) denoting the dimensions of the image. (n,m < 20). Each of the following n lines contains m values which represent the image.

    Output

    For each test case, print one line which contains the number of the test case, and the recognition result: ‘Zero’ or ‘Eight’. See the samples and follow the output format.

    Sample Input

     
    Input
    3
    8 10
    ..........
    ..*****...
    ..*...*...
    ..*...*...
    ..*****...
    ..*...*...
    ..*****...
    ..........
    6 10
    ..........
    ..*****...
    ..*...*...
    ..*...*...
    ..*****...
    ..........
    10 7
    .......
    .......
    .......
    .......
    ..****.
    ..*..*.
    ..****.
    ..*..*.
    ..****.
    .......
    Output
    Case 1: Eight
    Case 2: Zero
    Case 3: Eight
    /*
    给你一个字符矩阵让你判断里面*组成的团是8还是0
    
    只需要判断有几条横杠就行了,三条就是8,两条就是0
    */
    #include<stdio.h>
    #include<iostream>
    #include<algorithm>
    #include<string.h>
    #include<vector>
    #define N 25
    using namespace std;
    int main()
    {
        //freopen("in.txt","r",stdin);
        int t,n,m;
        char ch[N][N];
        scanf("%d",&t);
        for(int l=1;l<=t;l++)
        {
            int s=0;
            scanf("%d%d",&n,&m);
            getchar();
            for(int i=0;i<n;i++)
            {
                scanf("%s",&ch[i]);
                for(int j=0;j<m;j++)
                {
                    if(ch[i][j]=='*'&&ch[i][j+1]=='*'&&ch[i][j+2]=='*')
                    {
                        s++;
                        break;
                    }    
                }
            }
            //cout<<s<<endl;
            if(s>2)
                printf("Case %d: Eight
    ",l);
            else
                printf("Case %d: Zero
    ",l);
        }
        return 0;
    }
  • 相关阅读:
    一些C++11语言新特性
    项目管理计划应该包括哪些内容
    真相令人震惊!为什么越有钱的人,欠的钱越多?
    80后小伙返乡创业种植中药材,带领乡亲们脱贫致富
    Tableau
    知识点汇总
    决策树分析、EMV(期望货币值)
    信息系统项目管理师60天冲刺复习计划,2019下半年高项冲刺计划
    【系统分析师之路】系统分析师备考计划
    有一种规律:“劣币驱逐良币”,“坏人淘汰好人”(深度)
  • 原文地址:https://www.cnblogs.com/wuwangchuxin0924/p/5800971.html
Copyright © 2020-2023  润新知