reverse

Hello
Help please
I know that reversr function is:


void reverse( int numbers[], const int numbersLen)
{

for (int i = 0; i < numbersLen / 2; ++i)
{
int tmp = numbers[i];

int indexFromEnd = numbersLen - i - 1;

numbers[i] = numbers[indexFromEnd];

numbers[indexFromEnd] = tmp;
}
}



but why?... how we can put an array have the values 1234 to be printed in this way 4321?
what is the algorithm too?
What does mean your "why"?!!! Can you use a human language?!
If you know the reverse function then what is the problem? Use it to reverse elements of an array and then print it.
I mean what is the algorithm ... I know the code but I can't understand it
It takes the first element of the array and the last element of the array and exchanges their values. Then it takes the second element and the element before the last and again exchanges their values and so on.
Topic archived. No new replies allowed.