NYOJ366 D的小L next_permutation函数的用法

原题链接


#include <iostream>
#include <algorithm>
using namespace std;
char str[10];

int main(){
	int t, n;
	cin >> t;
	while(t--){
		cin >> n;
		for(int i = 1; i <= n; ++i)
			str[i - 1] = i + '0';
		str[n] = '\0';
		do{
			cout << str << endl;
		}while(next_permutation(str, str + n));
	}
	return 0;
}


posted on 2014-03-03 17:48  长木Qiu  阅读(161)  评论(0编辑  收藏  举报