C 区域内点的个数 SDUT


Description

X晚上睡不着的时候不喜欢玩手机,也不喜欢打游戏,他喜欢数星星。


Input

多组输入。

每组先输入一个整数N(N <= 10000),接着输入两个点代表矩形的左下点B(x,y)和右上点T(x,y),然后输入N个(X,Y)代表N颗星星。问有多少颗星星在窗子内部,在窗边上的不计。


Output

输出一个整数,代表有多少颗星星在窗子内部。


Sample
Input

3
0 1
3 4
1 1
2 2
3 3
2
1 1
5 5
4 4
0 6


Output

1
1


think:在区域内的点就是满足两坐标都小于范围边界的点;

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int i,n,temp,count=0;
    int a,b;
    int c,d;
    int e,f;
    while( scanf("%d",&n)!=EOF)
    {

    scanf("%d %d",&a,&b);
    scanf("%d %d",&c,&d); //输入范围;
    if(c>a)
    {
        temp=a;
        a=c;
        c=temp;
    }
    if(d>b)
    {
        temp=b;
        b=d;
        d=temp;
    }         //进行判断,方便下面进行判断;
    count=0;   //每一次都要初始化;
for(i=1;i<=n;i++)
{
    scanf("%d %d",&e,&f);
    if((e<a&&e>c)&&(f<b&&f>d))  
    //判断条件;
        count++;
}
 printf("%d\n",count);
    }


    return 0;
}
发布了136 篇原创文章 · 获赞 95 · 访问量 2308

猜你喜欢

转载自blog.csdn.net/zhangzhaolin12/article/details/103979516