{"id":371,"title":"\u9009\u62e9\u6392\u5e8f\u6cd5","good":0,"bad":0,"hit":1788,"created_at":"2018-07-18 11:10:59","content":"

\u5de5\u4f5c\u539f\u7406\u5982\u4e0b\u3002<\/span><\/p>

\u9996\u5148\u5728\u672a\u6392\u5e8f\u5e8f\u5217\u4e2d\u627e\u5230\u6700\u5c0f\u5143\u7d20\uff0c\u5b58\u653e\u5230\u6392\u5e8f\u5e8f\u5217\u7684\u8d77\u59cb\u4f4d\u7f6e\uff0c<\/span><\/p>

\u7136\u540e\uff0c\u518d\u4ece\u5269\u4f59\u672a\u6392\u5e8f\u5143\u7d20\u4e2d\u7ee7\u7eed\u5bfb\u627e\u6700\u5c0f\u5143\u7d20\uff0c\u7136\u540e\u653e\u5230\u6392\u5e8f\u5e8f\u5217\u672b\u5c3e\u3002<\/span><\/p>

\u4ee5\u6b64\u7c7b\u63a8\uff0c\u76f4\u5230\u6240\u6709\u5143\u7d20\u5747\u6392\u5e8f\u5b8c\u6bd5\u3002<\/span><\/p>

<\/span><\/p>

<?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    \/**\n     * \u9009\u62e9\u6392\u5e8f\u6cd5\n     * @return array\n     *\/\n    public function select_sort()\n    {\n        $num = count($this->data);\n        for ($i = 0; $i < $num; $i++) {\n            $position = $i;\n            for ($j = $i + 1; $j < $num; $j++) {\n                if ($this->data[$position] > $this->data[$j]) {\n                    $position = $j;\n                }\n            }\n            if ($position != $i) {\n                $temp = $this->data[$i];\n                $this->data[$i] = $this->data[$position];\n                $this->data[$position] = $temp;\n            }\n        }\n        return $this->data;\n    }\n}\n\n$obj = new suanfa();\nprint_r($obj->select_sort());\n\/**\nArray\n(\n    [0] => 1\n    [1] => 2\n    [2] => 3\n    [3] => 5\n    [4] => 8\n    [5] => 22\n    [6] => 87\n)\n * )\n *\/<\/pre>

<\/p>"}