package com.study.字符串排列;
public class WordPaixu {
public static void main(String[] args) {
String str="abcc";
diGui(str.getBytes(),new byte[str.getBytes().length],0,null, 0);
}
public static void diGui(byte[] sourceBytes,byte[] targetBytes,int level,Byte bb,int tempLength){
int byteLength = sourceBytes.length;
if (tempLength<byteLength){
tempLength=byteLength;
}
if (bb!=null && level<tempLength){
targetBytes[level]=bb;
}
if (byteLength!=0){
for (int i = 0; i <byteLength; i++) {
targetBytes[level]=sourceBytes[i];
bb=sourceBytes[i];
byte[] bytes2 = deleteAt(sourceBytes, i);
diGui(bytes2,targetBytes,level+1,bb,tempLength);
}
}else {
System.out.println(new String(targetBytes));
}
}
public static byte[] deleteAt(byte[] bs, int index)
{
int length = bs.length - 1;
byte[] ret = new byte[length];
System.arraycopy(bs, 0, ret, 0, index);
System.arraycopy(bs, index + 1, ret, index, length - index);
return ret;
}
}