Mar 23, 2010 at 12:46am UTC
So I'm doing an assignment that says i have to generate a random number between 0 and 999 and then use it to open an array that's storing a second column from an input file and i have no idea on how to attach the array to the random number i generate... here's what i have
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;
int std_dev(int variance);
int main(int argc, char *argv[])
{
double z[999];
double other[999];
char a, b;
float mean;
unsigned int seed;
ifstream zarray;
zarray.open("normal_distribution.txt");
srand(seed);
cout << "enter the mean value in the array " << endl;
cin >> mean;
cout << "your mean value is " << mean << endl;
cout << "enter a random number seed" << endl;
cin >> seed;
cout << "your seed is " << seed << endl;
zarray >> a;
zarray >> b;
for (int k=0; k>=1000++)
{
zarray >> other[k];
zarray >> z[k];
}
system("PAUSE");
return EXIT_SUCCESS;
}
int std_dev(int variance)
{
cout << "enter the variance " << endl;
cin >> variance;
cout << "your variance is " << variance << endl;
return sqrt(variance);
}