{"id":370,"title":"\u5192\u6ce1\u6392\u5e8f\u6cd5","good":0,"bad":0,"hit":2026,"created_at":"2018-07-18 10:42:18","content":"

\u6b65\u9aa4\uff1a<\/p>

  1. \u6bd4\u8f83\u76f8\u90bb\u7684\u5143\u7d20\u3002\u5982\u679c\u7b2c\u4e00\u4e2a\u6bd4\u7b2c\u4e8c\u4e2a\u5927\uff0c\u5c31\u4ea4\u6362\u4ed6\u4eec\u4e24\u4e2a\u3002<\/p><\/li>

  2. \u5bf9\u6bcf\u4e00\u5bf9\u76f8\u90bb\u5143\u7d20\u4f5c\u540c\u6837\u7684\u5de5\u4f5c\uff0c\u4ece\u5f00\u59cb\u7b2c\u4e00\u5bf9\u5230\u7ed3\u5c3e\u7684\u6700\u540e\u4e00\u5bf9\u3002\u5728\u8fd9\u4e00\u70b9\uff0c\u6700\u540e\u7684\u5143\u7d20\u5e94\u8be5\u4f1a\u662f\u6700\u5927\u7684\u6570\u3002<\/p><\/li>

  3. \u9488\u5bf9\u6240\u6709\u7684\u5143\u7d20\u91cd\u590d\u4ee5\u4e0a\u7684\u6b65\u9aa4\uff0c\u9664\u4e86\u6700\u540e\u4e00\u4e2a\u3002<\/p><\/li>

  4. \u6301\u7eed\u6bcf\u6b21\u5bf9\u8d8a\u6765\u8d8a\u5c11\u7684\u5143\u7d20\u91cd\u590d\u4e0a\u9762\u7684\u6b65\u9aa4\uff0c\u76f4\u5230\u6ca1\u6709\u4efb\u4f55\u4e00\u5bf9\u6570\u5b57\u9700\u8981\u6bd4\u8f83\u3002<\/p><\/li><\/ol>

    <?php\n\nclass suanfa\n{\n\n    private $data;\n\n    public function __construct()\n    {\n        $this->data = [87, 22, 5, 1, 2, 8, 3];\n    }\n\n    \/**\n     * \u5192\u6ce1\u6392\u5e8f\u6cd5\n     * @param $arr\n     *\/\n    public function maopao()\n    {\n        $num = count($this->data);\n        for ($i = 0; $i < $num; $i++) {\n            for ($j = 0; $j < $num - 1; $j++) {\n                if ($this->data[$j] > $this->data[$j + 1]) {\n                    $temp = $this->data[$j + 1];\n                    $this->data[$j + 1] = $this->data[$j];\n                    $this->data[$j] = $temp;\n                }\n            }\n        }\n        return $this->data;\n    }\n}\n\n$obj = new suanfa();\nprint_r($obj->maopao());<\/pre>

    Array<\/p>

    (<\/p>

        [0] => 1<\/p>

        [1] => 2<\/p>

        [2] => 3<\/p>

        [3] => 5<\/p>

        [4] => 8<\/p>

        [5] => 22<\/p>

        [6] => 87<\/p>

    )<\/p>

    <\/p>"}