1. No Profile Picture
Junior Member
Devshed Newbie (0 - 499 posts)

Join Date
Sep 2003
Posts
16
Rep Power
0

I am doing a program that declares a vector of real numbers, and inputs values until a 0 is entered. Add the values to the vector by using push_back(), and compute bothe the average and the maximum value of the numbers. Output the average and the maximum. The use double zero = 0.0; //start maxt at -infinity double max = -1.0/zero; These states will initialize max to have the infinity value. The first real number entered will become the new maximum.

I am not asking for anyone to write the code, but to tell me if anyone knows of any good websites that I can go to so I will understand about vectors better so I can do this program. I am totally confused on the whole vector thing. Thanks.
2. Vectors are really easy to use:

Code:
```#include <iostream>
#include <stdlib.h>
#include <vector>

using namespace std;

int main(){
int i, j;
vector < double > myVect;

srand(10);
//load up a bunch of data...
for (i=0; i<5; i++){
myVect.push_back((double) rand() + ((double)rand() / 1000.0));
}

cout << "Read data out using iterators...\n";
vector < double >::iterator iter = myVect.begin();
while (iter != myVect.end()){
cout << (*iter) << "\n";
iter++;
}

cout << "\n\nRead data out using array dereferencing...\n";
for (i=0; i<myVect.size(); i++){
cout << myVect[i] << "\n";
}

return 0;
}```
google for "vector" and "c++" and you should find plenty.