产生m个小于n的随机数

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
void getRandom(int m,int n){
int select=m;
int remain=n;
int i=0;
srand((int)time(0));    //设置随机数种子,必须
for(i=0;i<n;i++){
srand((int)time(0));
if(rand()%(remain-i)<m)//同上一节说的方法
    {
    printf("%d \n",i);
    m--;
    }
}
}
main()
{
getRandom(5,10);
}
原文地址:https://www.cnblogs.com/macula7/p/1960484.html