And if you know what it means to pass by reference, you will probably want to do that, in order to save the cost of a copy-destruction.

struct team
string name;
int skill;

void SimulateMatch(const team& t1, const team& t2)

Or you could use STL to do this for you applying the floor function on your vector and returning the result in another vector.


include <vector>
include <cmath>
include <algorithm>
include <functional>

int main()
typedef std::vector<double> Vec;
Vec first;
//Fill this vector with double values

Vec second(first.size());
std::pointer_to_unary_function <double, double> floorObject(std::floor);
std::transform(first.begin(), first.end(), second.begin(), floorObject);

return 0;



mrnutty commented: Nice, didn't know about pointer_to_unary_function +13

[QUOTE=flasp;1451454]The assignment says "Write a program that asks the user to type in numbers. After each entry, the program should report the cumulative sum of the entries to date. The program should terminate when the user enters 0."

I have partly been succesfull I guess. But I dont know how to make the program so it doesnt quit when I press the first number. And for it to actually quit when I press 0.. I hope a friendly soul can help me out.[/QUOTE]
You might want to decompose the problem in small sub-problems. So reading this assignment, you find out that you are required to do a few things :
[]get a number from the user
]compute a cumulative sum
[*]terminate the program when the user enters 0
You already achieved the first point with the usage of std::cin >> numbers. (and I'll make a note for myself to make sure the user entered a number. What would happen if the user entered a character ? But that's something you'll worry about afterwards).

For the second point, it seems you will need another variable to hold your running sum. Probably an int.

The third item is the one you're struggling with. So let's try to decompose it into even smaller problems. How do you terminate a program ? There are a few ways to do it, but it should normally terminate when you [I]return[/I] from your main function. And how do you return from your main function, well ...

jonsca commented: Nice explanation. Thanks for not giving the OP the answer. :) +6