C++全排列
来源:互联网 发布:淘宝如何设置发货地址 编辑:程序博客网 时间:2024/05/12 11:10
#include<iostream>
using namespace std;
void SWAP(int& a, int& b){
int s=a;
a=b;
int i;
if (k == m)
{
for (i = 0; i <= m; i++){
if(i<m){
cout << list [i]<<",";
}
else{
cout << list [i];}
}
cout << endl;
}
else
{
for (i=k; i <= m; i++)
{
SWAP (list[k], list[i]);
perm (list, k+1, m);
SWAP (list [k], list [i]);
}
}
}
int main(){
int in[10];
int d;
cout<<"Input"<<endl;
cin>>in[0];
cin>>in[1];
cin>>in[2];
for( d=2;d<10;d++){
while(in[d]!=0){
cin>>in[++d];
}
break;
}
d=d-1;
cout<<"Output"<<endl;
perm(in,0,d);
cout<<"End"<<endl;
return 0;
}
using namespace std;
void SWAP(int& a, int& b){
int s=a;
a=b;
b=s;
}
void perm(int list[], int k, int m){int i;
if (k == m)
{
for (i = 0; i <= m; i++){
if(i<m){
cout << list [i]<<",";
}
else{
cout << list [i];}
}
cout << endl;
}
else
{
for (i=k; i <= m; i++)
{
SWAP (list[k], list[i]);
perm (list, k+1, m);
SWAP (list [k], list [i]);
}
}
}
int main(){
int in[10];
int d;
cout<<"Input"<<endl;
cin>>in[0];
cin>>in[1];
cin>>in[2];
for( d=2;d<10;d++){
while(in[d]!=0){
cin>>in[++d];
}
break;
}
d=d-1;
cout<<"Output"<<endl;
perm(in,0,d);
cout<<"End"<<endl;
return 0;
}
- 全排列(C++)
- c 全排列
- C语言全排列
- C语言 全排列
- C++STL-全排列
- C/C++:全排列问题
- Algorithm--全排列(c#)
- 全排列C语言实现
- C语言实现全排列
- C语言实现全排列
- C语言实现全排列
- c++STl的全排列
- 【C++_STL_next_permutation】全排列讲解
- C 全排列 递归写法
- C++DFS方法全排列
- 字母全排列快速算法C代码
- 字母全排列快速算法C代码
- 字母全排列快速算法C代码
- 因在Windows 8.1中微软没有对版本API进行更新 导致桌面软件识别版本号为6.2.9200
- JDBC处理Transaction
- Linux下给挂载U盘或者SD卡
- POJ1287-最小生成树
- 简简单单---- (四)jsp内置对象request
- C++全排列
- assert宏的实现(一道笔试题)
- Java高级特性之CompareTo(一)
- 挣值管理不是搞数字游戏(1)——从搬石头的故事说起
- dp在图论中的应用
- c++学习笔记(第一次)
- HDU 1042 大数阶乘...
- 从软件设计角度下的操作系统发展轨迹——From the perspective of the software design of operating system course
- 【LeetCode】Single Number