题解 | #写一段程序判断IP字符串是否属于内网IP#
写一段程序判断IP字符串是否属于内网IP
http://www.nowcoder.com/practice/80ce674313ff43af9d7ac7a41ae21527
import java.io.*; import java.util.*; public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in); String s = sc.nextLine(); String[] ss = s.split("\\."); int a = Integer.parseInt(ss[0]); int b = Integer.parseInt(ss[1]); if((a == 10) || (a == 172 && (b >= 16 && b <= 32)) || (a == 192 && b == 168)){ System.out.println(1); }else{ System.out.println(0); } } }