HDU 6077

思路:

题目是给了一张字符画,然后让你识别出其中的数字并且输出。

我们观察一下这个图,这种“8”字形的数字一共有7条边,每条边有两个X,所以我们观察从0~9这十个数发现。
在这里插入图片描述

我们可以确定1,4,7,8这四个数字的X的个数,对于其他的情况分别讨论:

标记一下
在这里插入图片描述

然后观察图发现四个数字所处的位置:

(0,0)~(6,3)

(0,5)~(6,8)

(0,12)~(6,15)

(0,17)~(6,20)

我们把这四个区域遍历一遍,找特征就行

代码:

#include <cstdio>
#include <cstring>
#include <cctype>
#include <string>
#include <set>
#include <iostream>
#include <stack>
#include <cmath>
#include <queue>
#include <vector>
#include <algorithm>
#define mem(a,b) memset(a,b,sizeof(a))
#define inf 0x3f3f3f3f
#define N 300
#define ll long long
using namespace std;
char s[30][30];
int jc(int x1,int y1,int x2,int y2)
{
	int sum=0;
	int n1=0,n2=0,n3=0,n4=0,n5=0,n6=0,n7=0;
	if(s[1][y1]=='X'&&s[2][y1]=='X') n2=1;
	if(s[4][y2]=='X'&&s[5][y2]=='X') n7=1;
	if(s[3][y1+1]=='X'&&s[3][y1+2]=='X') n4=1;
	if(s[1][y2]=='X'&&s[2][y2]=='X') n3=1;
	for(int i=x1; i<=x2; i++)
		for(int j=y1; j<=y2; j++)
			if(s[i][j]=='X')
				sum++;
	if(sum==4) return 1;
	else if(sum==8) return 4;
	else if(sum==6) return 7;
	else if(sum==14) return 8;
	else if(sum==12)
	{
		if(!n4)
			return 0;
		else if(n3)
			return 9;
		else
			return 6;
	}
	else if(sum==10)
	{
		if(n2)
			return 5;
		else if(n7)
			return 3;
		else
			return 2;
	}
}
int main()
{
	int t,a,b,c,d;
	scanf("%d",&t);
	while(t--)
	{
		for(int i=0; i<7; i++)
			scanf("%s",s[i]);
		a=jc(0,0,6,3);
		b=jc(0,5,6,8);
		c=jc(0,12,6,15);
		d=jc(0,17,6,20);
		printf("%d%d:%d%d\n",a,b,c,d);
	}
	return 0;
}

————————————————
版权声明:本文为CSDN博主「riba2534」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/riba2534/article/details/76638894

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值