for_each

What I have done is use also the algorithm < for_each() > .

Why ?

You show 2 loops. I showed a third one, the algorithm of the STL.

Very interesting the :    for (int v: var)...    I am not use to using it.