对于我正在编写的程序,我需要创建一个具有用户定义大小的数组,以及 -15 到 15 之间的随机值。因此,我将 srand 与动态数组转换一起使用。这是我的完整代码如下:
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main()
{
//initialize variables
double minValue;
double maxValue;
double firstQuartile;
double thirdQuartile;
double skewness;
int size;
std::cout << "Please enter the size of the data set: "; //get data set size from user
std::cin >> size;
int* dataSet = new int[size];
cout << endl << "These are the randomly generated values: ";
srand(static_cast<unsigned int>(time(NULL)));
int i = size;
for (int x = 0; …Run Code Online (Sandbox Code Playgroud)