public static void main(String[] args){ Scanner input = new Scanner(System.in); String[] ips = new String[4]; for(int i=0; i<4; i++){ ips[i] = input.nextLine(); } int ip1,ip2,ip3,ip4; String[] tmp = new String[4]; for(int i=0; i<4; i++){ tmp[i] = (ips[i].split("\\."))[0]; } ip1 = Integer.parseInt(tmp[0]); ip2 = Integer.parseInt(tmp[1]); ip3 = Integer.parseInt(tmp[2]); ip4 = Integer.parseInt(tmp[3]); //不相交 if(ip1 <= ip2){ if((ip3<ip1 && ip4<ip1) || (ip3>ip2 && ip4>ip2)){ System.out.println(" No Overlap IP"); }else{ System.out.println("Overlap IP"); } }else{ if((ip3<ip2 && ip4<ip2) || (ip3>ip1 && ip4>ip1)){ System.out.println(" No Overlap IP"); }else{ System.out.println("Overlap IP"); } } }
点赞 评论

相关推荐

牛客网
牛客企业服务