递归实现,思路的确有点难得想:
public void SortAll(List<string> list,int start,int end) { if (start==end) { foreach (var item in list) { Console.Write(item); } Console.WriteLine(); } else { for (int i = start; i < end; i++) { //交换变量 var temp = list[start]; list[start] = list[i]; list[i] = temp; //递归排序 SortAll(list,start+1,end); //还原变量 temp = list[start]; list[start] = list[i]; list[i] = temp; } } }