#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;
}
}
原文:http://www.cnblogs.com/bohat/p/7912693.html