public class AllSortAlgorithm {

	public static void main(String[] args) {
		
		char[] array = {'a','b','c'};
		allsort(array,0,array.length);
	}
	
	private static void swap(char[] array , int i , int j){
		
		if(i != j){
			array[i]^=array[j];array[j]^=array[i];array[i]^=array[j];
		}
	}
	
	private static void allsort(char[] array , int start , int end){
		
		if(start < end-1){
			for(int i = start ; i < end; i++){
				swap(array , i , start);
				allsort(array , start+1 , end);
				swap(array , i , start);
			}
		}else{
			for(int i = 0 ; i < end ; i++) System.out.print(array[i]);
			System.out.println();
		}
	}
}

 

posted on 2013-10-05 15:37  真心的不懂  阅读(318)  评论(0编辑  收藏  举报