-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrandomarray.cpp
41 lines (40 loc) · 1.25 KB
/
randomarray.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/*#include <iostream>
#include <stdint.h>
#include <fstream>
#include "randomarray.hpp"
RandomArray::RandomArray (uint32_t length, int32_t left_border, int32_t right_border): array_length_(length), arrayi_(new int32_t[length])
{
srand(time(0));
for (uint32_t i = 0; i < array_length_; ++i)
{
arrayi_[i] = rand() % (right_border - left_border) + left_border; //constructor for array of random numbers
}
}
RandomArray::RandomArray (uint32_t length, float left_border, float right_border): array_length_(length), arrayf_(new float[length])
{
srand(time(0));
for (uint32_t i = 0; i < array_length_; ++i)
{
arrayf_[i] = static_cast <float>(rand()) / static_cast <float>(RAND_MAX) * // float cosntructs of array
(right_border - left_border) + left_border; // from int rand() function
}
}
void RandomArray::array_exporti(){
std::ofstream obj;
obj.open("Array.bin");
for (uint32_t i = 0; i < array_length_; ++i)
{
obj << arrayi_[i] << ' ';
}
obj.close();
}
void RandomArray::array_exportf(){
std::ofstream obj;
obj.open("Array.bin");
for (uint32_t i = 0; i < array_length_; ++i)
{
obj << arrayf_[i] << ' ';
}
obj.close();
}
*/