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

📄 perm.cpp

📁 这是有关数据结构的例程序
💻 CPP
字号:
#include <iostream>

using namespace std;

template <class Type>
inline void Swap(Type &a, Type &b)
{
	Type temp = a;
	a = b;
	b = temp;
}

template <class Type>
void Perm(Type list[], int k, int m)
{
	int i;

	if(k==m){
		for(i=0; i<=m; i++)
			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()
{
	char list[3]={'1','[','3'};
	Perm(list, 0, 2);
	return 0;
}

⌨️ 快捷键说明

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