读书人

数目字随机排列算法

发布时间: 2013-03-25 15:43:04 作者: rapoo

数字随机排列算法
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);         }         }    }    }

??

读书人网 >编程

热点推荐