zoukankan      html  css  js  c++  java
  • 老子的全排列呢

    链接:https://www.nowcoder.com/acm/contest/76/H
    来源:牛客网

    老子的全排列呢
    时间限制:C/C++ 1秒,其他语言2秒
    空间限制:C/C++ 32768K,其他语言65536K
    64bit IO Format: %lld

    题目描述

    老李见和尚赢了自己的酒,但是自己还舍不得,所以就耍起了赖皮,对和尚说,光武不行,再来点文的,你给我说出来1-8的全排序,我就让你喝,这次绝不耍你,你能帮帮和尚么?

    输入描述:

    输出描述:

    1~8的全排列,按照全排列的顺序输出,每行结尾无空格。
    示例1

    输入

    No_Input

    输出

    Full arrangement of 1~8

    备注:

    1~3的全排列  :
    1 2 3
    1 3 2
    2 1 3
    2 3 1
    3 1 2
    3 2 1

    AC代码:
    #include<iostream>
    #include<algorithm>
    using namespace std;
    void permutation(char* str, int length)
    {
        sort(str, str + length);
        do
        {
            int i;
            for (i = 0; i<length-1; i++)
                cout << str[i]<<" ";
            cout << str[i] << endl;
        } while (next_permutation(str, str + length));
    }
    int main()
    {
        char str[] = "12345678";
        permutation(str, 8);
        system("pause");
        return 0;
    }

    今天也是元气满满的一天!good luck!

  • 相关阅读:
    JQ分页练习
    Dom1
    JQ轮播图
    Dom操作
    DYR
    jQ点击事件
    [z]vc boost安装
    [z] .net与java建立WebService再互相调用
    [z]
    git常用命令二
  • 原文地址:https://www.cnblogs.com/cattree/p/8511208.html
Copyright © 2011-2022 走看看