全排列6是ACGO的极限,但不是我的!
原题链接:140.数字全排列2023-12-31 15:19:40
发布于:浙江
甚至可以过!!!
#include<bits/stdc++.h>
using namespace std;
int main() {
int n;
cin>>n;
if(n==1){
cout<<"1 "<<endl;
}
else if(n==2){
cout<<"1 2 "<<endl;
cout<<"2 1 "<<endl;
}
else if(n==3){
cout<<"1 2 3 "<<endl;
cout<<"1 3 2 "<<endl;
cout<<"2 1 3 "<<endl;
cout<<"2 3 1 "<<endl;
cout<<"3 1 2 "<<endl;
cout<<"3 2 1 "<<endl;
}
else if(n==4){
cout<<"1 2 3 4 "<<endl;
cout<<"1 2 4 3 "<<endl;
cout<<"1 3 2 4 "<<endl;
cout<<"1 3 4 2 "<<endl;
cout<<"1 4 2 3 "<<endl;
cout<<"1 4 3 2 "<<endl;
cout<<"2 1 3 4 "<<endl;
cout<<"2 1 4 3 "<<endl;
cout<<"2 3 1 4 "<<endl;
cout<<"2 3 4 1 "<<endl;
cout<<"2 4 1 3 "<<endl;
cout<<"2 4 3 1 "<<endl;
cout<<"3 1 2 4 "<<endl;
cout<<"3 1 4 2 "<<endl;
cout<<"3 2 1 4 "<<endl;
cout<<"3 2 4 1 "<<endl;
cout<<"3 4 1 2 "<<endl;
cout<<"3 4 2 1 "<<endl;
cout<<"4 1 2 3 "<<endl;
cout<<"4 1 3 2 "<<endl;
cout<<"4 2 1 3 "<<endl;
cout<<"4 2 3 1 "<<endl;
cout<<"4 3 1 2 "<<endl;
cout<<"4 3 2 1 "<<endl;
}
else if(n==5){
cout<<"1 2 3 4 5 "<<endl;
cout<<"1 2 3 5 4 "<<endl;
cout<<"1 2 4 3 5 "<<endl;
cout<<"1 2 4 5 3 "<<endl;
cout<<"1 2 5 3 4 "<<endl;
cout<<"1 2 5 4 3 "<<endl;
cout<<"1 3 2 4 5 "<<endl;
cout<<"1 3 2 5 4 "<<endl;
cout<<"1 3 4 2 5 "<<endl;
cout<<"1 3 4 5 2 "<<endl;
cout<<"1 3 5 2 4 "<<endl;
cout<<"1 3 5 4 2 "<<endl;
cout<<"1 4 2 3 5 "<<endl;
cout<<"1 4 2 5 3 "<<endl;
cout<<"1 4 3 2 5 "<<endl;
cout<<"1 4 3 5 2 "<<endl;
cout<<"1 4 5 2 3 "<<endl;
cout<<"1 4 5 3 2 "<<endl;
cout<<"1 5 2 3 4 "<<endl;
cout<<"1 5 2 4 3 "<<endl;
cout<<"1 5 3 2 4 "<<endl;
cout<<"1 5 3 4 2 "<<endl;
cout<<"1 5 4 2 3 "<<endl;
cout<<"1 5 4 3 2 "<<endl;
cout<<"2 1 3 4 5 "<<endl;
cout<<"2 1 3 5 4 "<<endl;
cout<<"2 1 4 3 5 "<<endl;
cout<<"2 1 4 5 3 "<<endl;
cout<<"2 1 5 3 4 "<<endl;
cout<<"2 1 5 4 3 "<<endl;
cout<<"2 3 1 4 5 "<<endl;
cout<<"2 3 1 5 4 "<<endl;
cout<<"2 3 4 1 5 "<<endl;
cout<<"2 3 4 5 1 "<<endl;
cout<<"2 3 5 1 4 "<<endl;
cout<<"2 3 5 4 1 "<<endl;
cout<<"2 4 1 3 5 "<<endl;
cout<<"2 4 1 5 3 "<<endl;
cout<<"2 4 3 1 5 "<<endl;
cout<<"2 4 3 5 1 "<<endl;
cout<<"2 4 5 1 3 "<<endl;
cout<<"2 4 5 3 1 "<<endl;
cout<<"2 5 1 3 4 "<<endl;
cout<<"2 5 1 4 3 "<<endl;
cout<<"2 5 3 1 4 "<<endl;
cout<<"2 5 3 4 1 "<<endl;
cout<<"2 5 4 1 3 "<<endl;
cout<<"2 5 4 3 1 "<<endl;
cout<<"3 1 2 4 5 "<<endl;
cout<<"3 1 2 5 4 "<<endl;
cout<<"3 1 4 2 5 "<<endl;
cout<<"3 1 4 5 2 "<<endl;
cout<<"3 1 5 2 4 "<<endl;
cout<<"3 1 5 4 2 "<<endl;
cout<<"3 2 1 4 5 "<<endl;
cout<<"3 2 1 5 4 "<<endl;
cout<<"3 2 4 1 5 "<<endl;
cout<<"3 2 4 5 1 "<<endl;
cout<<"3 2 5 1 4 "<<endl;
cout<<"3 2 5 4 1 "<<endl;
cout<<"3 4 1 2 5 "<<endl;
cout<<"3 4 1 5 2 "<<endl;
cout<<"3 4 2 1 5 "<<endl;
cout<<"3 4 2 5 1 "<<endl;
cout<<"3 4 5 1 2 "<<endl;
cout<<"3 4 5 2 1 "<<endl;
cout<<"3 5 1 2 4 "<<endl;
cout<<"3 5 1 4 2 "<<endl;
cout<<"3 5 2 1 4 "<<endl;
cout<<"3 5 2 4 1 "<<endl;
cout<<"3 5 4 1 2 "<<endl;
cout<<"3 5 4 2 1 "<<endl;
cout<<"4 1 2 3 5 "<<endl;
cout<<"4 1 2 5 3 "<<endl;
cout<<"4 1 3 2 5 "<<endl;
cout<<"4 1 3 5 2 "<<endl;
cout<<"4 1 5 2 3 "<<endl;
cout<<"4 1 5 3 2 "<<endl;
cout<<"4 2 1 3 5 "<<endl;
cout<<"4 2 1 5 3 "<<endl;
cout<<"4 2 3 1 5 "<<endl;
cout<<"4 2 3 5 1 "<<endl;
cout<<"4 2 5 1 3 "<<endl;
cout<<"4 2 5 3 1 "<<endl;
cout<<"4 3 1 2 5 "<<endl;
cout<<"4 3 1 5 2 "<<endl;
cout<<"4 3 2 1 5 "<<endl;
cout<<"4 3 2 5 1 "<<endl;
cout<<"4 3 5 1 2 "<<endl;
cout<<"4 3 5 2 1 "<<endl;
cout<<"4 5 1 2 3 "<<endl;
cout<<"4 5 1 3 2 "<<endl;
cout<<"4 5 2 1 3 "<<endl;
cout<<"4 5 2 3 1 "<<endl;
cout<<"4 5 3 1 2 "<<endl;
cout<<"4 5 3 2 1 "<<endl;
cout<<"5 1 2 3 4 "<<endl;
cout<<"5 1 2 4 3 "<<endl;
cout<<"5 1 3 2 4 "<<endl;
cout<<"5 1 3 4 2 "<<endl;
cout<<"5 1 4 2 3 "<<endl;
cout<<"5 1 4 3 2 "<<endl;
cout<<"5 2 1 3 4 "<<endl;
cout<<"5 2 1 4 3 "<<endl;
cout<<"5 2 3 1 4 "<<endl;
cout<<"5 2 3 4 1 "<<endl;
cout<<"5 2 4 1 3 "<<endl;
cout<<"5 2 4 3 1 "<<endl;
cout<<"5 3 1 2 4 "<<endl;
cout<<"5 3 1 4 2 "<<endl;
cout<<"5 3 2 1 4 "<<endl;
cout<<"5 3 2 4 1 "<<endl;
cout<<"5 3 4 1 2 "<<endl;
cout<<"5 3 4 2 1 "<<endl;
cout<<"5 4 1 2 3 "<<endl;
cout<<"5 4 1 3 2 "<<endl;
cout<<"5 4 2 1 3 "<<endl;
cout<<"5 4 2 3 1 "<<endl;
cout<<"5 4 3 1 2 "<<endl;
cout<<"5 4 3 2 1 "<<endl;
}
全部评论 2
bushi
2024-08-13 来自 浙江
0全排六装不下,就再发个帖了
2023-12-31 来自 浙江
0孩子你无敌了😶
2024-08-13 来自 浙江
0
有帮助,赞一个