csu oj 1330 字符识别?

http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1330

1330: 字符识别?

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 419  Solved: 296
[Submit][Status][Web Board]

Description

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

.*.  ***  ***

.*.  ..*  ..*

.*.  ***  ***

.*.  *..  ..*

.*.  ***  ***

Input

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

Output

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

Sample Input

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

Sample Output

123

分析:

直接判断a[4][1] a[4][3] a[4][3]是否等于“*” 即可。



AC代码:

 1 #include <stdio.h>
 2 #include <algorithm>
 3 #include <iostream>
 4 #include <string.h>
 5 #include <string>
 6 #include <math.h>
 7 #include <stdlib.h>
 8 #include <queue>
 9 #include <stack>
10 #include <set>
11 #include <map>
12 #include <list>
13 #include <iomanip>
14 #include <vector>
15 #pragma comment(linker, "/STACK:1024000000,1024000000")
16 #pragma warning(disable:4786)
17 
18 using namespace std;
19 
20 const int INF = 0x3f3f3f3f;
21 const int MAX = 1000 + 10;
22 const double eps = 1e-8;
23 const double PI = acos(-1.0);
24 
25 int main()
26 {
27     int n , i;
28     char str[7][57];
29     scanf("%d",&n);
30     for(i = 1;i <= 5;i ++)
31         cin >> str[i] + 1;
32     n *= 4;
33     for(i = 1;i <= n;i += 4)
34     {
35         if(str[4][i] == '*')
36             cout << "2";
37         else if(str[4][i + 1] == '*')
38             cout << "1";
39         else
40             cout << "3";
41     }
42     puts("");
43     return 0;
44 }
View Code
原文地址:https://www.cnblogs.com/jeff-wgc/p/4456439.html