c++字符串的排列组合
2015-06-16 15:09
302 查看
#include <iostream> #include <string.h> using namespace std; static int sum = 0; void Swap(char &a, char &b) { char tmp = a; a = b; b = tmp; } void Grial(char *s1, char *s2) { if (s1 == NULL || s2 == NULL)return; if (*s2 == '\0') cout << s1 << endl; for (char *p = s2; *p != '\0'; p++) { //sum++; Swap(*p,*s2); Grial(s1,s2+1); //if (*p!=*s2) Swap(*p,*s2); } // cout << sum << endl; } void Grial(char *str) { Grial(str, str); } int main() { char *str = new char[5]; strcpy(str,"12345"); Grial(str); }
相关文章推荐
- C++虚函数讲解
- C++ Custom Control控件 向父窗体发送对应的消息
- c++ vector用法
- 使用C/C++编写PHP Extension
- C++xml文件操作 CMarkup学习方法说明(转)
- 网狐棋牌经典版管理后台操作手册
- C++ 11.2 accumulate、find_first_of 函数
- C++的iostream标准库介绍+使用详解(转)
- c语言计算一个日期的下一天后N天后的日期
- C++ 智能指针详解
- c++中#pragma的用法
- C++【重载,覆盖,隐藏三者的区别】
- 【C++】注释转换详解 C++注释转换为标准C语言注释
- [C/CPP系列知识] 那些程序C语言可以编译通过但C++无法编译成功 Write a C program that won’t compile in C++
- C++课后习题作业
- C++ mkdir() 头文件
- 北京c++技术交流 235760268
- C\C++代码优化的27个建议
- 【整理】--C++变量概述
- C++中代理类和句柄类