zoukankan      html  css  js  c++  java
  • Java练习 SDUT-2749_区域内点的个数

    区域内点的个数

    Time Limit: 1000 ms Memory Limit: 65536 KiB

    Problem 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

    Sample Output

    1

    import java.util.*;
    
    public class Main
    {
    	static int x1,y1,x2,y2;
    	public static void main(String[] args)
    	{
    		Scanner cin = new Scanner(System.in);
    		int n,t,i,x,y,num;
    		while(cin.hasNextLine())
    		{
    			n = cin.nextInt();
    			x1 = cin.nextInt();
    			y1 = cin.nextInt();
    			x2 = cin.nextInt();
    			y2 = cin.nextInt();
    			if(x1>x2)
    			{
    				t = x1;
    				x1 = x2;
    				x2 = t;
    			}
    			if(y1>y2)
    			{
    				t = y1;
    				y1 = y2;
    				y2 = t;
    			}
    			num = 0;
    			for(i=0;i<n;i++)
    			{
    				x = cin.nextInt();
    				y = cin.nextInt();
    				if(judge(x,y)==1)
    					num++;
    			}
    			System.out.println(num);
    		}
    		cin.close();
    	}
    	static int judge(int x,int y)
    	{
    		if(x>x1&&x<x2&&y>y1&&y<y2)
    			return 1;
    		return 0;
    	}
    }
    
  • 相关阅读:
    mysql 性能监控
    拼接字符
    mysql 存储 2
    mysql 存储过程
    flock
    readfile() file_get_content f
    url_encode和base64
    jsdetox反混淆js内容,解密前端加密参数
    前端加密之使用firefox来解密
    v to ray做渗透测试
  • 原文地址:https://www.cnblogs.com/luoxiaoyi/p/9930535.html
Copyright © 2011-2022 走看看