using accumulate and vectors is pretty neat also:

Code:`int num;`

vector<int> nums;

while (cin >> num ) nums.push_back(num);

double avg = accumulate( nums.begin(), nums.end(), 0.0 ) / nums.size();

Printable View

- 01-18-2008dra
using accumulate and vectors is pretty neat also:

Code:`int num;`

vector<int> nums;

while (cin >> num ) nums.push_back(num);

double avg = accumulate( nums.begin(), nums.end(), 0.0 ) / nums.size();

- 01-18-2008KIBO
- 01-18-2008laserlightQuote:

using accumulate and vectors is pretty neat also:

- 01-18-2008dra
If i needed to find the mean, I wouldn't have used that code...

just something interesting to learn about. :)