public class SortText
{
public static void main(String[] args)
{
for(int i=10000;i<100000;i++){
Integer ceshi=(Integer)i;
demo(ceshi.toString());
}
List<String> list=new ArrayList<String>();
for(String st1:set){
list.add(st1);
}
System.out.println(list+"这些数都是能构成数字黑洞的循环数"+"+发现一个规律:10000--100000之间的5位数正反两次循环排序差"都是这个集合里面的数");
}
public static void demo(String str1)
{
String a=str1;
Integer v=sortText(a,4);
String str4=sb2.toString();
v=sortText(a,5);
String v1=v.toString();
if(str4.contains(v1)&&sb2.length()>30){
sortText(a,4);
String hj=sb2.substring(6, 11);
set.add(hj);
}
}
static HashSet<String> set=new HashSet<String>();
static StringBuilder sb2=new StringBuilder();
static StringBuilder sb1=new StringBuilder();
static int j=0;
public static int sortText(String str,int a){
if(a==4|a==5){sb2.delete(0, sb2.length());sb2.append(str+",");}
for(int i=0;i<a;i++){
char[] ch=str.toCharArray();
if(ch.length ==5){
Arrays.sort(ch);
sb1.append(ch);
String min=sb1.toString();
String max=sb1.reverse().toString();
sb1.delete(0, sb1.length());
Integer distance=(Integer)(Integer.parseInt(max)-Integer.parseInt(min));
j=distance;
String dis=distance.toString();
str=dis;
if(dis.toCharArray().length==5){
sb2.append(j+",") ;}
}
}
return j;
}
} |