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\n",str[j]); } } return 0; }
【推荐】100%开源!大型工业跨平台软件C++源码提供,建模,组态!
【推荐】2025 HarmonyOS 鸿蒙创新赛正式启动,百万大奖等你挑战
【推荐】博客园的心动:当一群程序员决定开源共建一个真诚相亲平台
【推荐】开源 Linux 服务器运维管理面板 1Panel V2 版本正式发布
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步