⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 prg15_4.cpp

📁 数据结构c++语言描述stl版 威廉兄弟的好书,值得看,这是配书代码
💻 CPP
字号:
// File: prg15_4.cpp
// the program prompts for an integer n and
// initializes a vector with the values {1,2,3,...,n}.
// it then calls the recursive function permute() that
// displays all n! permutations of the numbers 1 .. n

#include <iostream>
#include <vector>

#include "d_perm.h"		// for permute()

using namespace std;

int main()
{
	int n,i;
	vector<int> permList;
			
	cout << "Enter the size of the permutation list: ";
	cin >> n;

	for (i=0; i < n; i++)
		permList.push_back(i+1);	// initialize the vector
	cout << endl;

	// start creating permutation ordering at index 0
	permute(permList,0);
				
	return 0;
}

/*
Run:

Enter the size of the permutation list: 3

1  2  3
1  3  2
2  1  3
2  3  1
3  1  2
3  2  1
*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -