随机算法
1 void ShuffleArray_Fisher_Yates(char* arr, int len)
2 {
3 int i = len, j;
4 char temp;
5
6 if ( i == 0 ) return;
7 while ( --i ) {
8 j = rand() % (i+1);
9 temp = arr[i];
10 arr[i] = arr[j];
11 arr[j] = temp;
12 }
13 }
2 {
3 int i = len, j;
4 char temp;
5
6 if ( i == 0 ) return;
7 while ( --i ) {
8 j = rand() % (i+1);
9 temp = arr[i];
10 arr[i] = arr[j];
11 arr[j] = temp;
12 }
13 }