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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值