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

📄 string_perm_example.cpp

📁 利用递归查找数字的排列组合 使用了STL技术
💻 CPP
字号:
// recvperm.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"


#include <string>
#include <iostream>

using namespace std;


void string_permutation( std::string& orig, std::string& perm )
{
	if( orig.empty() )
	{
		std::cout<<perm<<std::endl;
		return;
	}

	for(int i=0;i<orig.size();++i)
	{
		std::string orig2 = orig;

		orig2.erase(i,1);

		std::string perm2 = perm;
		
		perm2 += orig.at(i);

		string_permutation(orig2,perm2);

	} 
}

int main()
{
  
	std::string orig="ABCDE";
	std::string perm;  

	string_permutation(orig,perm);

	cout<<"Complete!"<<endl;

	system("pause");

	return 0;
}

⌨️ 快捷键说明

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