Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
361085 黄浙峰老师 【C6-7】全排列 C++ 通过 100 69 MS 248 KB 424 2025-11-15 13:23:03

Tests(6/6):


#include<bits/stdc++.h> using namespace std; int n; int p[10]; bool a[10]; void hsg(int x){ if(x==n){ for(int i=0;i<n;i++){ cout<<p[i]<<" "; } puts(" ");//换行 return ; } for(int i=1;i<=n;i++){ if(!a[i]){ a[i]=true; p[x]=i; //枚举位置上数字的可能性 hsg(x+1); //下一层 a[i]=false; //恢复现场 } } } int main(){ cin>>n; hsg(0); return 0; }


测评信息: