标签:style blog color io ar for div sp log
引用剑指offer
1 //字符串全排列,begin始终指向当前要置换的字符串 2 void permutation(char* str,char* begin){ 3 if(!str || !begin) 4 return; 5 if(*begin==‘\0‘){ 6 cout<<str<<" "; 7 return; 8 } 9 else{ 10 for(char* p=begin;*p!=‘\0‘;p++){ 11 //交换*p和*begin 12 swap(*p,*begin); 13 permutation(str,begin+1); 14 //重新换回*P和*begin 15 swap(*p,*begin); 16 } 17 } 18 }
标签:style blog color io ar for div sp log
原文地址:http://www.cnblogs.com/liuzhiminxd/p/3983050.html