zoukankan      html  css  js  c++  java
  • C

    C - 字符识别?
    Time Limit:1000MS     Memory Limit:131072KB     64bit IO Format:%lld & %llu

    Description

    你的任务是写一个程序进行字符识别。别担心,你只需要识别1, 2, 3,如下:

    .*.  ***  ***

    .*.  ..*  ..*

    .*.  ***  ***

    .*.  *..  ..*

    .*.  ***  ***

    Input

    输入仅包含一组数据,由6行组成。第一行为字符的个数n(1<=n<=10)。以下5行每行包含4n个字符。每个字符恰好占5行3列,然后是一个空列(用"."填充)。

    Output

    输出应包含一行,即识别出的各个字符。

    Sample Input

    3.*..***.***..*....*...*..*..***.***..*..*.....*..*..***.***.

    Sample Output

    123 
    my answer:
    #include<iostream>
    #include<string>
    #include<cstring>
    #define MAX 300
    using namespace std;
    int main()
    {
    	int n;
    	while(cin>>n)
    	{
    		char a[MAX][MAX];
    		int t[100]={0},i=0;
    		for( i=0;i!=5;i++)
    		  cin>>a[i];
            for( i=0;i!=n;i++){
            	if(a[3][i*4]=='.'&&a[3][i*4+1]=='*'&&a[3][i*4+2]=='.')t[i]=1;
            	else if(a[3][i*4]=='*'&&a[3][i*4+1]=='.'&&a[3][i*4+2]=='.')t[i]=2;
            	else if(a[3][i*4]=='.'&&a[3][i*4+1]=='.'&&a[3][i*4+2]=='*')t[i]=3;
            }
            for(int j=0;j!=i;j++)
              cout<<t[j];
            cout<<endl;
    	}
    	return 0;
    }


  • 相关阅读:
    Python2 和 Python3的区别 更新中
    CentOS下图形界面安装_Orcaale 11g
    Nmap_使用介绍
    shell_innobackup增量备份步骤
    shell_跳板机推送公钥
    shell_clean_log
    shell_xtrabackup_backup_mysql
    gitlab免密登录
    gitlab安装与部署
    git合并分支
  • 原文地址:https://www.cnblogs.com/NYNU-ACM/p/4248798.html
Copyright © 2011-2022 走看看