bnu 4351 美女来找茬(水水)

http://www.bnuoj.com/bnuoj/problem_show.php?pid=4351

【题意】:用最小的矩形框,框住像素点差超过5的点。

【题解】:求坐标x,y最大最小值

【code】:

 1 #include <iostream>
 2 #include <stdio.h>
 3 #include <string.h>
 4 #include <algorithm>
 5 
 6 using namespace std;
 7 
 8 int map[220][220];
 9 
10 int abs(int x)
11 {
12     return x<0?-x:x;
13 }
14 
15 int main()
16 {
17     int n,m;
18     scanf("%d%d",&n,&m);
19     int i,j;
20     for(i=0;i<n;i++)
21     {
22         for(j=0;j<m;j++)
23         {
24             scanf("%d",&map[i][j]);
25         }
26     }
27     int x;
28     int x1=1111,x2=-1,y1=1111,y2=-1;
29     int exist=0;
30     for(i=0;i<n;i++)
31     {
32         for(j=0;j<m;j++)
33         {
34             scanf("%d",&x);
35             if(abs(map[i][j]-x)>5)
36             {
37                 exist=1;
38                 if(x1>i)    x1=i;
39                 if(x2<i)    x2=i;
40                 if(y1>j)    y1=j;
41                 if(y2<j)    y2=j;
42             }
43         }
44     }
45     if(exist)
46     {
47         printf("%d %d %d %d\n",x1+1,y1+1,x2+1,y2+1);
48     }
49     else
50     {
51         puts("-1");
52     }
53     return 0;
54 }

 

转载于:https://www.cnblogs.com/crazyapple/p/3327099.html

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值