-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathrnddet.cpp
More file actions
53 lines (47 loc) · 1.26 KB
/
rnddet.cpp
File metadata and controls
53 lines (47 loc) · 1.26 KB
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
#include <iostream>
#include "rnddet.h"
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
// Constructors ********************************************************
/*RNDDET::RNDDET(double val)
{
Value = val; // double:
LValue = (long)(val + 1e-11); // rounds off!!!
}
RNDDET::RNDDET(long lval)
{
Value = (double)lval; // integer
LValue = lval; // less critical
}
*/
// output operator *****************************************************
ostream& operator<<(ostream& outp, RNDDET& gen)
{
outp << "RNDDET (" << gen.Value
<< "), EX = " << gen.Value << ", VarX = " << 0.0;
return outp;
}
// main program for a demonstration of generator output ****************
//#ifdef SINGLE
int main()
{ srand(time(NULL));
double val;
int no;
cout << "value? ";
cin >> val;
cout << "no.? ";
cin >> no;
RNDDET RD(val);
cout << RD << ":" << endl;
for (int i = 0; i < no; i++)
{
printf("%6.3lf", RD.Rnd());
if (i % 10 == 9)
cout << endl;
else
cout << "\t";
}
return 0;
}
//#endif