|
常用鏈接
留言簿(4)
隨筆分類
隨筆檔案
搜索
最新評論

閱讀排行榜
評論排行榜
Powered by: 博客園
模板提供:滬江博客
|
|
|
|
|
發新文章 |
|
|
STL的排序應用
#include <stdio.h>
#include <algorithm>

using namespace std;

 int main() {
long m,n,k,i;
long a[1024];
scanf("%ld",&m);
 while (m--) {
scanf("%ld%ld",&n,&k);
for (i=0;i<n;i++) scanf("%ld",&a[i]);
for (i=1;i<=k;i++)
if (!(next_permutation(a,a+n)))
sort(a,a+n);
for (i=0;i<n;i++) printf("%ld ",a[i]);
printf("\n");
};
return 0;
};

|
|