输出一串数字的全排列
来源:互联网 发布:怎么做微信淘宝优惠群 编辑:程序博客网 时间:2024/05/16 09:14
/* 算法:输出数字串的全排列*/#include <iostream>#include <list>#include <string>using namespace std;//删除str的第n个字符void DeleteCharAt(string& strSrc, int pos){if (pos < 0 || pos >= strSrc.length()){return;}string tmpStr(strSrc.substr(pos + 1));strSrc = strSrc.substr(0, pos) + tmpStr;}//递归函数void RecurListAll(string& strBase, string strBuf, list<string>& retList){if (strBase.length() <= 0){retList.push_back(strBuf);}for(int i = 0; i < strBase.length(); i++){string tmp(strBase);DeleteCharAt(tmp, i);RecurListAll(tmp, strBuf + strBase[i], retList); }}int main(int argc, char* argv[]){string str = "123";list<string> retList;RecurListAll(str, "", retList);//Here: retList --> ("123","132","213","231","312","321")return 0;}
- 输出一串数字的全排列
- 一组数字的全排列按序输出
- hdu 1716 排列2 输出几个数字的全排列
- 输出两个数字间全部数字的全排列
- 输入一串数字输出最大的数字
- 数字的全排列
- 数字的全排列
- 数字的全排列
- 全排列的输出
- 求一串字符串的全排列和所有组合
- 数字的全排列 问题
- Permutations 数字的全排列
- 输出字符串的全排列
- 输出字符串的全排列
- 输出n的全排列
- 输出全排列的方案
- 输出字符串的全排列
- 输出字符串的全排列
- (原创)斗牛游戏 初版
- 应用MIME将ZPT内容输出为excel文件(word文件)
- android 数据插入异常
- 第7集 构造函数中抛出的异常
- 互联网进入网盘新时代
- 输出一串数字的全排列
- php 匿名函数和use子句的使用
- Session变量在Zope中的使用
- Android众多开源项目推荐
- Linux上配置Nginx+PHP5(FastCGI)
- VC++中进程间相互通信的十一种方法
- Linux常用的库函数dlopen/dlsym
- pdffactory 安装时StartService 失败
- Android 之 Dialog 使用总结