-
Notifications
You must be signed in to change notification settings - Fork 0
/
shuffle.cc
63 lines (48 loc) · 1.16 KB
/
shuffle.cc
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <string>
using namespace std;
int NUM_SIZE=52;
int myrandom (int i)
{
return std::rand()%i;
}
int main()
{
vector<int> r;
int count = 0;
int filecount = 0;
srand(time(0));
ofstream myfile;
myfile.open("output" + to_string(filecount) + ".csv");
for(int i=0; i < NUM_SIZE; i++) //Added numbers to the vector
{
r.push_back(i);
}
random_shuffle(r.begin(), r.end(), myrandom); //Do the first shuffle
while (true)
{
if (is_sorted(r.begin(), r.end())) //Check to see if the vector is sorted
break;
random_shuffle(r.begin(), r.end(), myrandom); //Shuffle the vector
for (int i=0; i < NUM_SIZE; i++) //Add the vector contents into the csv
{
myfile << r[i] << ",";
}
myfile << "\n";
if (count >= 999999) //If the file has more than 995000 line in it, Make a new file
{
count = 0;
filecount++;
myfile.close();
myfile.open("output" + to_string(filecount) + ".csv");//Open the new file
}
count++;
}
myfile.close();
return 0;
}