-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmonte.cpp
More file actions
58 lines (49 loc) · 1012 Bytes
/
monte.cpp
File metadata and controls
58 lines (49 loc) · 1012 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
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
#include <iostream>
#include "monte.h"
Monte::Monte()
{
}
void Monte::Run(double batches, double samples,double items)
{
cout << "Analyzing Data Sets: " << endl << endl;
Random object;
int randomnumber;
fstream f;
ostringstream os;
string temp=".txt",s;
bool decision=true;
for(double i=1; i<=batches;i++)
{
decision=true;
os.str("");
temp.clear();
os << "ds" << i << ".txt";
temp = os.str();
f.open(temp);
for(double j=1; j<=samples; j++)
{
s.clear();
randomnumber=object.getrand(items); // generate a random number from 1 to amount of items in a particular batch
GotoLine(f,randomnumber);
f>>s;
if(s=="b")
{decision=false;}
}
f.close();
if(decision)
{//good file
}
else
{// bad file
cout << "File #" <<i << " is bad ." << endl;
}
}
}
fstream& Monte::GotoLine(fstream& file, unsigned int num)
{
file.seekg(ios::beg);
for(int i=0; i < num - 1; ++i){
file.ignore(numeric_limits<streamsize>::max(),'\n');
}
return file;
}