赞
踩
class Solution{ public: int combination(string str){ int num=0; int n =str.size(); string strLen; dfs(str,strLen,n,num,0); return num; }; void dfs(string&str,string&strLen,const int&n,const int&index){ if(index==n){ cout<<strLen<<endl; num++; return ; } for (size_t i = index; i < n; i++) { strLen+=str[i]; swap(str[index],str[i]); dfs(str,strLen,n,index+1); strLen.erase(strLen.end()-1); swap(str[index],str[i]); } } }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。