标签:edit ble 有一个 表示 queue cst nbsp 限制 ++
2 2 3
12 21 123 132 213 231 312 321
/** 分析:这道题就是求由 1--n 组成的数字的全排列 方法:next_permutation(); 模板: do{ for (int i = 0; i < n; ++ i) printf ("%d", A[i]); printf ("\n"); } while (next_permutation(A, A + n)); **/
C/C++代码实现:
#include <iostream> #include <algorithm> #include <cstring> #include <cmath> #include <cstdio> #include <stack> #include <queue> using namespace std; int main () { int T; scanf ("%d", &T); while (T --) { int n, X[12]; scanf ("%d", &n); for (int i = 0; i < n; ++ i) X[i] = i + 1; do { for (int i = 0; i < n; ++ i) printf ("%d", X[i]); printf ("\n"); } while (next_permutation (X, X + n)); } return 0; }
标签:edit ble 有一个 表示 queue cst nbsp 限制 ++
原文地址:https://www.cnblogs.com/GetcharZp/p/8973929.html