Run ID | Author | Problem | Lang | Verdict | Time | Memory | Code Length | Submit Time |
---|---|---|---|---|---|---|---|---|
58733 | teacher_wang | 全排列 | C++ | Accepted | 0 MS | 252 KB | 506 | 2024-12-15 12:27:26 |
#include<bits/stdc++.h> using namespace std; int main() { int n,a[10],cnt=0; cin>>n; // ① 创建原序列 for(int i = 1; i <= n; i ++) a[i] = i; // ② 对序列进行全排列 do{ // 对每一次排列只需要输出即可 for(int i = 1; i <= n; i ++) cout<<a[i]; cnt ++; cout<<endl; }while(next_permutation(a+1,a+n+1)); //序列起始位置是下标为1的位置 cout<<cnt; return 0; }