博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
全排列函数
阅读量:4570 次
发布时间:2019-06-08

本文共 721 字,大约阅读时间需要 2 分钟。

void perm (int A[], int n, int k){if (k == n) print( A , n );else    for (int i = k;i < n; i++)   {    swap(A[i],A[k]);    perm (A,n,k+1);    swap(A[i],A[k]);   }}//下面有验证代码#include 
#include
using namespace std;ofstream outfile ("out.txt");int A[100];void print ( int A[] , int n){for (int i = 1 ; i < n; i++){ cout<
<<" "; outfile<
<<" "; }outfile<
<
< n; i++) { swap(A[i],A[k]); perm (A,n,k+1); swap(A[i],A[k]); }}int main (){ for (int i = 0; i < 100; i++) A[i]=i;int n;cout<<"请输入排列数的个数:"<
> n;perm (A , n+1, 1);return 0;}

转载于:https://www.cnblogs.com/Chinese-Coder-Clarence/articles/2039240.html

你可能感兴趣的文章
使用c++实现一个FTP客户端(三)
查看>>
ffmpeg 转换VC工具已经可以生成工程文件(续)
查看>>
OpenGL + C++ + Java
查看>>
UOJ #15 虫洞路线
查看>>
一些较好的书
查看>>
绑定一个值给radio
查看>>
友晶Sdram_Control_4Port的全页操作Bug?
查看>>
用MVC5+EF6+WebApi 做一个小功能(一)开场挖坑,在线答题系统
查看>>
box-shadow详解
查看>>
线段树——HYSBZ - 3224
查看>>
EF6+SQLite3数据库出现类型转换失败的问题(指定的转换无效)
查看>>
谷歌希望让 Swift 成为安卓的优先选择,以取代由 Oracle 开发的 Java 程序语言。...
查看>>
Windsock套接字I/O模型学习 --- 第一章
查看>>
浏览器兼容问题笔记
查看>>
OUTLOOK+VBA 备份邮件到GMAIL
查看>>
谁说delphi没有IOCP库,delphi新的IOCP类库,开源中: DIOCP组件JSON流模块说明
查看>>
[四种方法]检测数据类型
查看>>
chrome使用技巧 值得珍藏
查看>>
【IT笔试面试题整理】数组中出现次数超过一半的数字
查看>>
cocos下的UI编辑器--BoomEditor使用教程(1)--快速上手
查看>>