猿问

急,在线等,两个随机数组重复问题

如图
代码如下
void randnums(int *arr, int n)
{
int datalength = n;
do {
srand((unsigned)time(NULL)); //用时间做种,每次产生随机数不一样
int  number = random(datalength);
datalength--;
int tmp = arr[number];
arr[number] = arr[datalength];
arr[datalength] = tmp;
} while (datalength>0);
}
调用两次函数,数组重复


慕容8255747
浏览 926回答 2
2回答

慕设计2395807

YOKGBXNQMWLPLOEGJZPLBEEZPFOEHWTOWBQFIYAWGPFUVQGPKGPSOYBNVSOYADMOEHXBQTPZPEUKMODZPYOQZPFBTIRZPEUXNWZFBXNPGBQNDMTJYVYOROKHQSAQGBLAWZCSYNWMIRHWMIYWXHWNBKGPZPZGARBUDOLVLPTVZWFOKHQMKZCZCMQMJZVDROEGWTQMVLYHWUDTWZPLBMVXFCFVRNQNVMVWZVTCYORQFOYILHJZOXQFBRHXTUQUXTJSBCYCYVYGYNCZBRURNILLUVEUKAKMJEHWZXTPZKZPYYHQGDMNWGCYXZBRBPTWRHJMBKNCSCFOEAKSIEAXNWSCLBOWTRNJSNKAPLNWZNDADMOSBILHEHRNJMRLUKMCSIEADNAPFISISBETPDZBDTQLIYUCLVEHWTKTHXKTPFBKNQEHQENPSIYNJTIYMTIRORTWSVEWSUXGPSXNWYXFHDTCSVYNJLNQGJMPRBXTEMJFOJMJLIXMOYBYBXAWXTZOYIRAOFIEORNQKNJUYBEZMHKTWTPMPYAIKFIFHRHKGCAJRBDTWFIRHIKMCEZISPSORNPMORARUKMPSUZCFPRFCLWXTCLCFPLIRIRGDMQMILVYAJRHWTPLOLAAWMJZPRHJFPEMPLUKTWSIXEUXAPFBEGWGORMJSVYVLURNJFVLHCFVYBLAQHKUJZBRNBRGDZVLUKNJRTWXNPMORNJFNQEHQUJFPSGVLOYNQKTDMWEVLBRNWXHQZVRAWMPDTWYBEBWTWSBEHQPXUYIKNJZILYHWMPGCEBPSYBJZPRHWMIYPXGJETQAJMPYGOQUKAWLBYUJEBKBXMCFOUBEURNRNJSVQRIEAJACSOYYHDMIYOYTJMDGOROETWSTJ
随时随地看视频慕课网APP
我要回答