int* GetRandomSequence2(int total) { int* sequence = new int[total]; int* output = new int[total]; for (int i = 0; i < total; i++) { sequence[i] = i; } int end = total - 1; for (int i = 0; i < total; i++) { int num=rand()%end; output[i] = sequence[num]; sequence[num] = sequence[end]; end--; } delete []sequence; return output; } 利用交换的思想。