-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata_generator.cpp
More file actions
31 lines (27 loc) · 802 Bytes
/
data_generator.cpp
File metadata and controls
31 lines (27 loc) · 802 Bytes
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
#include <iostream>
#include <string>
#include <cstdlib>
#include <time.h>
#include <fstream>
void write_data_to_txt(int n);
double random_double();
int main(int argc, char** argv){
int n_data = std::atoi(argv[1]);
write_data_to_txt(n_data);
}
void write_data_to_txt(int n) {
srand(time(NULL));
std::string outfile_name = std::string("data_50000");
std::ofstream outfile (outfile_name);
outfile<<n<<std::endl;
for (int q = 0; q < n ; ++q) {
outfile<<random_double()<<","<<random_double()<<","<<random_double()<<","<<random_double()<<","<<random_double()<<std::endl;
}
outfile.close();
}
double random_double(){
double random_number;
random_number = (double)rand()/RAND_MAX;
random_number = 1 + random_number*(50-1);;
return random_number;
}