#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;
}
}
时间: 2024-10-16 17:04:18