packagecom.liuzhen.systemExe;importjava.util.HashSet;importjava.util.Scanner;importjava.util.Set;public classMain{public void getReverseN(intn){
Set set = new HashSet();for(int i = 0;i < 10;i++){int x1 =i;for(int j = 0;j < 10;j++){int x2 =j;for(int k = 0;k < 10;k++){int x3 =k;if(2*(x1+x2)+x3 ==n){char[] temp = new char[5];
temp[0] = (char) (x1 + 48);
temp[1] = (char) (x2 + 48);
temp[2] = (char) (x3 + 48);
temp[3] = (char) (x2 + 48);
temp[4] = (char) (x1 + 48);
String tempS1=String.valueOf(temp);
set.add(tempS1);
temp[0] = (char) (x2 + 48);
temp[1] = (char) (x1 + 48);
temp[2] = (char) (x3 + 48);
temp[3] = (char) (x1 + 48);
temp[4] = (char) (x2 + 48);
String tempS2=String.valueOf(temp);
set.add(tempS2);
}if(2*(x1+x2+x3) ==n){char[] temp = new char[6];
temp[0] = (char) (x1 + 48);
temp[1] = (char) (x2 + 48);
temp[2] = (char) (x3 + 48);
temp[3] = (char) (x3 + 48);
temp[4] = (char) (x2 + 48);
temp[5] = (char) (x1 + 48);
String tempS1=String.valueOf(temp);
set.add(tempS1);
temp[0] = (char) (x1 + 48);
temp[1] = (char) (x3 + 48);
temp[2] = (char) (x2 + 48);
temp[3] = (char) (x2 + 48);
temp[4] = (char) (x3 + 48);
temp[5] = (char) (x1 + 48);
String tempS2=String.valueOf(temp);
set.add(tempS2);
temp[0] = (char) (x2 + 48);
temp[1] = (char) (x1 + 48);
temp[2] = (char) (x3 + 48);
temp[3] = (char) (x3 + 48);
temp[4] = (char) (x1 + 48);
temp[5] = (char) (x2 + 48);
String tempS3=String.valueOf(temp);
set.add(tempS3);
temp[0] = (char) (x2 + 48);
temp[1] = (char) (x3 + 48);
temp[2] = (char) (x1 + 48);
temp[3] = (char) (x1 + 48);
temp[4] = (char) (x3 + 48);
temp[5] = (char) (x2 + 48);
String tempS4=String.valueOf(temp);
set.add(tempS4);
temp[0] = (char) (x3 + 48);
temp[1] = (char) (x2 + 48);
temp[2] = (char) (x1 + 48);
temp[3] = (char) (x1 + 48);
temp[4] = (char) (x2 + 48);
temp[5] = (char) (x3 + 48);
String tempS5=String.valueOf(temp);
set.add(tempS5);
temp[0] = (char) (x3 + 48);
temp[1] = (char) (x1 + 48);
temp[2] = (char) (x2 + 48);
temp[3] = (char) (x2 + 48);
temp[4] = (char) (x1 + 48);
temp[5] = (char) (x3 + 48);
String tempS6=String.valueOf(temp);
set.add(tempS6);
}
}
}
}int len =set.size();
String[] result= newString[len];int i = 0;for(String tem : set)
result[i++] =tem;int[] rI =getSort(result);for(i = 0;i < len;i++){int k =getMinI(rI);
System.out.println(result[k]);
rI[k]=len;
}
}public int[] getSort(String[] A){int len =A.length;int[] result = new int[len];int[] tempResult = new int[len];for(int i = 0;i < len;i++){
tempResult[i]=Integer.parseInt(A[i]);
}for(int i = 0;i < len;i++){int count = 0;for(int j = 0;j < len;j++){if(tempResult[i] >tempResult[j])
count++;
}
result[i]=count;
}returnresult;
}public int getMinI(int[] A){int result = 0;for(int i = 0;i < A.length;i++){if(A[result] >A[i])
result=i;
}returnresult;
}public static voidmain(String[] args){//long t1 = System.currentTimeMillis();
Main test = newMain();
Scanner in= newScanner(System.in);
System.out.println("请输入一个10进制整数:");int n =in.nextInt();
test.getReverseN(n);//long t2 = System.currentTimeMillis();//System.out.println("耗时:"+(t2-t1)+"毫秒");
}
}