//"192.168.0.1 1.10.3.75 65.32.86.95 198.156.0.1 89.83.255"按IP地址进行地址段顺序排序
import java.util.*;
class dz
{
public static void sop(Object obj)
{
System.out.println(obj);
}
public static void main(String[] args)
{
String str="192.168.0.1 1.10.3.75 65.32.86.95 198.156.0.1 89.83.255";
xiaoyan(str);
}
public static void xiaoyan(String str)
{
str=str.replaceAll("(\\d+)","00$1");
str=str.replaceAll("0*(\\d{3})","$1");
TreeSet<String> s=new TreeSet<String>();
String[] k=str.split(" +");
for(String name:k)
{
s.add(name);
}
for(String name:s)
{
sop(name.replaceAll("0*(\\d+)","$1"));
}
}
}
|
|