2009-12-09

vector的sum

用accumulate。
MSDN有例子:
...
// Sum the array
cout << "The sum of 1 + 1/2 + 1/3 + ... + 1/10 is " << accumulate(rgFA.begin(),rgFA.end(),0.0f) << endl;
...

No comments: