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"); } } }
点赞 评论

相关推荐

01-18 09:26
已编辑
门头沟学院 Java
王桑的大offer:建议中间件那块写熟悉即可,写掌握 面试包被拷打到昏厥
点赞 评论 收藏
分享
kl_我是东山啊:《相关公司:阿里巴巴》
投递阿里巴巴等公司10个岗位
点赞 评论 收藏
分享
牛客网
牛客企业服务