Description
Input
Output
Sample Input
3 3 1 2 3 1 3 1 3 2 1 10 2 1 2 3 4 5 6 7 8 9 10
Sample Output
3 1 2 1 2 3 1 2 3 4 5 6 7 9 8 10
#include<iostream> #include<cstdio> #include<algorithm> using namespace std; int num[1200]; int main() { int n,i,k,s; scanf("%d",&n); while(n--) { scanf("%d%d",&k,&s); for(i=0;i<k;i++) scanf("%D",&num[i]); while(s--) next_permutation(num,num+k); cout<<num[0]; for(i=1;i<k;i++) printf(" %d",num[i]); cout<<endl;} return 0; }
原文:http://blog.csdn.net/rememberautumn/article/details/37756773