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;
}


转载于:https://www.cnblogs.com/NYNU-ACM/p/4248798.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值