#4
civilherui2016-03-09 21:35
一个随机抽取函数:
#include<iostream>
#include<stdlib.h>
#include<time.h>
using namespace std;
int choose(int total); // 建立 1~total 序列 ,然后随机抽取 返回
int main()
{
cout<<choose(10)<<endl;
}
int choose(int total)
{
srand(time(NULL));
int i;
return(rand()%total+1);
}
|