123456这几个数,给出所有的排序可能,并第二个数不能4,34不能连在一起
public static void main(String[] args) { for(int i=123456;i<=654321;i++){ String s=""+i; if(s.indexOf("4")!=2&&!s.contains("34")&&s.contains("1")&&s.contains("2")&&s.contains("3")&&s.contains("4")&&s.contains("5")&&s.contains("6")){ System.out.println(i); } } }
// 冒泡实现 @Test public void test1(){ int[] arr=new int[]{2,4,1,66,33}; for(int i=0;i<arr.length;i++){ for(int j=0;j<arr.length-1-i;j++){ if(arr[j]>arr[j+1]){ int temp=arr[j]; arr[j]=arr[j+1]; arr[j+1]=temp; } } } System.out.println(Arrays.toString(arr)); }
//简单递归实现 public static int digui(int i){ if(i==1){ return 1; } return i+digui(i-1); }
//递归遍历文件夹名字 public static void pp(File file){ if(file!=null){ if(file.isDirectory()){ File[] files=file.listFiles(); if(files!=null){ for(File f:files){ pp(f); } } }else{ System.out.println(file); } } }
//任意给出一个数返回汉字 比如 1024 返回一千零二十四 public static void change(int number){ //数字对应的汉字 String[] num = {"零","一","二","三","四","五","六","七","八","九"}; //单位 String[] unit = {"","十","百","千","万","十","百","千","亿","十","百","千","万亿"}; //将输入数字转换为字符串 String result = String.valueOf(number); //将该字符串分割为数组存放 char[] ch = result.toCharArray(); //结果 字符串 String str = ""; int length = ch.length; for (int i = 0; i < length; i++) { int c = (int)ch[i]-48; if(c != 0) { str += num[c]+unit[length-i-1]; } else { str += num[c]; } } System.out.println(str); }