This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void sort(int[] arr) { | |
int min, k; | |
for (int i = 0; i < arr.length - 1; i++) { | |
min = arr[i]; | |
k = i; | |
for (int j = i + 1; j < arr.length; j++) { | |
if (arr[j] < min) { | |
k = j; | |
min = arr[j]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void quickSort(int[] arr, int low, int high) { | |
if (low < high) { | |
int first = low; | |
int last = high; | |
int key = arr[low]; | |
while (first < last) { | |
while (first < last && key <= arr[last]) { | |
last--; | |
} | |
// 将比第一个小的放到首端 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 思想:随机交换 | |
* | |
* @param arr | |
*/ | |
public static void shuffle(int[] arr) { | |
Random r = new Random(); | |
int size = arr.length; | |
for (int i = size; i > 1; i--) { | |
int random = r.nextInt(i); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
error_reporting ( 0 ); | |
header ( 'Content-Type:text/html;charset=utf-8' ); | |
// 常量参数 | |
define ( 'DB_HOST', 'localhost' ); | |
define ( 'DB_USER', 'root' ); | |
define ( 'DB_PWD', 'root' ); | |
define ( 'DB_NAME', 'inerd' ); |