您的位置:首页 > 其它

可重集的排列:投机取巧的做法,利用STL的next_permutation

2015-06-04 21:48 393 查看
#include <iostream>  
#include <algorithm>  
using namespace std;  

int main()  
{  
	int p[5] = {4, 1, 1, 4, 1};
	sort(p, p+5);	//排序
	do 
	{
		for (int i = 0; i < 5; i++)
		{
			printf("%d ", p[i]);
		}
		printf("\n");
	} while (next_permutation(p, p+5));
	return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: