标签:ret int random time return for ++ 控制 srand
#pragma once
#include <iostream>
using namespace std;
#include <ctime>
#include <assert.h>
namespace sorttesthelper
{
int* generaterandomarray(int n, int rangl, int rangr)
{
assert(rangl <= rangr);
int *arr = new int[n];
srand(time(NULL));
for (int i = 0; i < n; i++)
arr[i] = rand() % (rangr - rangl + 1) + rangl; //将rand的范围控制在【rangl,rangr】这个闭环内。
return arr;
}
}
标签:ret int random time return for ++ 控制 srand
原文地址:http://www.cnblogs.com/bohat/p/7912693.html