在一个数组中将数据打乱
#include <stdio.h>
#include<string.h>
void printArray(int *arry, int n) {
for (int i = 0; i < n; i++) {
printf("%d ", arry[i]);
}
}
int main() {
int arry[11] = { 1,2,3,4,5,6,7,8,9,10,11 };
srand(time(0));
for (int i = 0; i < 11; i++) {
int r = rand() % 11;
int t = arry[i];
arry[i] = arry[r];
arry[r] = t;
}
printArray(arry, 11);
return 0;
}