Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) Exercise #7: AddOne

 

Difficulty: 2/10

Date added: 24th of June 2008

 

In this exercise, you learn that different ways to the same solution, yield different execution speeds.

 

Below is a declaration of a function to add one to every int in a std::vector:

 

void AddOne(std::vector<int>& v);

 

There are many ways to do this.

 

Question #0: How many correct ways are there to do this? Hint: more than 10.

 

Question #1: Write a program that tests which way is fastest

 

View the answer of this exercise.

 

 

 

 

 

Post your feedback

 

Feel encouraged to post your feedback about this exercise at Programmer's Heaven.

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict