#include<bits/stdc++.h>
using namespace std;
const double PI=acos(-1.0);
#define _max -0x7fffffff
int main()
{
int n; // 1<=n<=11
while(scanf("%d",&n)!=EOF)
{
vector<int>A;
for(int i=1;i<=n;i++)
A.push_back(i);
int FLAG=1;
int P=0;
while(FLAG)
{
P++;
int flag=1;
for(int j=0;j<n-1;j++)
{
if(A[j]%2==A[j+1]%2) //我去一直把取余写成了除法
{
flag=0;
break;
}
}
if(flag==1)
{
for(int t=0;t<n;t++)
printf("%d ",A[t]);
printf("\n");
}
FLAG=next_permutation(A.begin(),A.end());
}
}
return 0;
}
07-21
7402
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
07-18
1万+
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交