Question
How to make this program work by changing the ouput and operator function ? #include #include #include using namespace std; unsigned int seed = (unsigned
How to make this program work by changing the ouput and operator function ?
#include
#include
#include
using namespace std;
unsigned int seed = (unsigned int)time(0);
const int SIZE = 10;
struct node
{
int integer;
double value;
};
double random(unsigned int &);
void initialize_vector(vector
void print_vector(const vector
ostream &operator << (ostream &, vector
void output(ostream &, vector
int main()
{
vector
initialize_vector(v);
print_vector(v);
for (int i = 0; i < v.size(); ++i)
cout << v[i];
cout << endl;
return 0;
}
void initialize_vector(vector
{
vector
for (it = v.begin(); it < v.end(); ++it)
{
it -> integer = (int (10 * random(seed)));
it -> value =(10 * random(seed));
}
}
void print_vector(const vector
{
cout << setprecision(5) << fixed;
for (int i = 0; i < v.size(); ++i)
cout << v.at(i).integer << setw(12) << v.at(i).value < } ostream &operator << (ostream &out, vector { output(out,v); return(out); } void output(ostream &out, vector { cout << setprecision(5) << fixed << endl; cout << "Overriding print: " << endl; for(int i = 0; i < v.size(); ++i) cout << v[i].integer << setw(12) << v[i].value << endl; } double random(unsigned int & seed) { const int MODULUS = 15749; const int MULTIPLIER = 69069; const int INCREMENT = 1; seed = ((MULTIPLIER * seed) + INCREMENT) % MODULUS; return double (seed) / double (MODULUS); }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started