33,028
社区成员
发帖
与我相关
我的任务
分享#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
int main()
{
int k[20];
int i = 0;
int index = 0;
int temp = 0;
for(i=0; i<20; ++i){
k[i] = i%8;
}
srand((unsigned)time(0));
for(i=20; i>0; --i){
index = rand()%i;
temp = k[index];
k[index] = k[i-1];
k[i-1] = temp;
}
for(i=0; i<20; ++i)
printf("%d ",k[i]);
printf("\n");
return 0;
}