简单思维 #小红的排列构造# 分成奇数和偶数两种情况

#include <iostream>
using namespace std;

void odd (int x)
{
    for (int i = 1; i <= x; i ++ )
    {
        cout << x - i + 1 << " ";
    }
}

int main() {
    int n;
    cin >> n;
    if (n <= 2)
    {
        cout << -1 << endl;
        return 0;
    }
    if (n % 2 == 0)
    {
        odd(n - 1);
        cout << n;
    }
    else {
        odd(n);
    }
}
// 64 位输出请用 printf("%lld")


全部评论

相关推荐

点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务