POJ 1833 生成排列

题目链接:POJ 1833

/************************************
*              author        :  Grant Yuan
*              time            :   2014/10/19 16:38
*              source        :   POJ 1833
*              algorithm:    STL+排列的生成
*************************************/
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
int str[1030];
int ans[1030];
int n,k,t;
int main()
{
   scanf("%d",&t);
    while(t--){
        memset(str,0,sizeof(str));
        scanf("%d%d",&n,&k);
        for(int i=0;i<n;i++)
        {
            scanf("%d",&str[i]);
        }
        for(int i=1;i<=k;i++)
        {
                bool b=next_permutation(str,str+n);
        }
      for(int j=0;j<n;j++)
        {
              if(j!=n-1)  printf("%d ",str[j]);
               else printf("%d
",str[j]);
        }
    }
    return 0;
}


原文地址:https://www.cnblogs.com/codeyuan/p/4254408.html