思路:转换成二进制,再转换成整数,再比较大小。
import java.math.BigInteger;
import java.util.Scanner;
/**
* Created by wangxi on 2019/6/26.
*/
public class TT {
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
String str1=in.nextLine();
String str2=in.nextLine();
String str3=in.nextLine();
String ch1[]=str1.split("\\.");
String ch2[]=str2.split("\\.");
String ch3[]=str3.split("\\.");
StringBuffer s1=new StringBuffer();
StringBuffer s2=new StringBuffer();
StringBuffer s3=new StringBuffer();
System.out.println(ch1.length);
for(int i=0;i<ch1.length;i++){
String temp1=new String(new BigInteger(ch1[i]).toString(2));
String temp2=new String(new BigInteger(ch2[i]).toString(2));
String temp3=new String(new BigInteger(ch3[i]).toString(2));
for(int j=0;j<8-temp1.length();j++)
s1.append(0);
for(int j=0;j<8-temp2.length();j++)
s2.append(0);
for(int j=0;j<8-temp3.length();j++)
s3.append(0);
s1.append(temp1);
s2.append(temp2);
s3.append(temp3);
}
System.out.println(s1+" "+s2+" "+s3);
int num1=Integer.parseInt(s1.toString(),2);
int num2=Integer.parseInt(s2.toString(),2);
int num3=Integer.parseInt(s3.toString(),2);
boolean flag=false;
if(num1<= num3 && num3<=num2)
flag=true;
else if(num1>=num3 && num3>=num2)
flag=true;
System.out.println(flag);
}
}