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

相关推荐

10-21 00:37
已编辑
山东大学 C++
小浪_Coding:你问别人,本来就是有求于人,别人肯定没有义务免费回答你丫, 有点流量每天私信可能都十几,几十条的,大家都有工作和自己的事情, 付费也是正常的, 就像你请别人搭把手, 总得给人家买瓶水喝吧
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务