1330: Character Recognition? Time Limit: 1 sec memory limit: 128 MB
Submit: 158 solved: 100
[Submit] [Status] [web board] Description
Your task is to write a program for character recognition. Don't worry, you only need to identify 1, 2, 3, as follows:
.*.******
.*...*..*
.*.******
.*.*....*
.*.******
Input
The input contains only one group of data, which consists of six rows. The first row contains N (1 <=n <= 10) characters ). Each row of the following five rows contains 4 n characters. Each character exactly occupies five rows and three columns, followed by an empty column (filled ).
Output
The output should contain one line, that is, each character recognized.
Sample Input
3.*..***.***..*....*...*..*..***.***..*..*.....*..*..***.***.
Sample output
123
Hintsource
Hunan ninth College Computer Program Design Competition
To determine the number of characters, you only need to check the position of * in each of the four characters in the fourth row of the array.
#include<iostream>#include<cstring>using namespace std;int main(){ int n,k,i,j; char a[5][45],b[5]; memset(a,0,sizeof(a)); cin>>n; for(i=0;i<5;i++) for(j=0;j<4*n;j++) cin>>a[i][j]; /*for(j=0;j<4*n;j++) cout<<a[3][j]<<" "; cout<<endl; */ for(j=1;j<=n;j++) { int l=1; for(i=4*(j-1);i<4*j;i++) { b[l]=a[3][i]; if(b[l]=='*') { k=l; //cout<<k<<endl; if(k==2) cout<<'1'; else if(k==1) cout<<'2'; else cout<<'3'; } l++; } } cout<<endl;}