求下一個排列模板
#include#include #include #include using namespace std; int main() { int n,m; while(scanf("%d%d",&n,&m)!=EOF){ int i; int a[1005]; for(i=1;i<=n;i++) a[i]=i; m--; while(m--){ next_permutation(a+1,a+1+n); } for(i=1;i<=n;i++){ if(i==1) printf("%d",a[i]); else printf(" %d",a[i]); } printf("\n"); } }