c++ 全排列算法

#include "stdafx.h"
#include <string>
#include <algorithm>
#include <iostream>

void func(const char *str_in)
{
	std::string str(str_in);
	std::sort(str.begin(),str.end());
	do 
	{
		std::cout<<str<<std::endl;
	}while (std::next_permutation(str.begin(),str.end()));
}

int _tmain(int argc, _TCHAR* argv[])
{
	func("cab");
	return 0;
}

  

posted on 2013-03-07 11:00  jxgxy  阅读(936)  评论(0编辑  收藏  举报

导航