数字随机排列算法
class Group{static String[] numbers = new String[]{"1","2","2","3","4","5"};public static boolean isGroup(String str){ for(String number:numbers){ if(str.indexOf(number)<0){//过滤掉不同时存在这些1、2、2、3、4、5数字的组合 return false; } if(str.indexOf("22")<0){//过滤掉“22”不在一起的数据 return false; } } return true; }}
?测试类:
public class Test { public static void main(String args[]) { for(int x = 122345;x<543221;x++){ if(Group.isGroup(String.valueOf(x))){ System.out.println(x); } } } }??