Write a recursive function that mirrors the elements in an array.
Prototype : void mirror(int tab[], int start, int end)
Write a main function to test your program.
Difficulty level
This exercise is mostly suitable for students
void exchange(int *a, int *b)
{
int c=*a;
*a=*b;
*b=c;
}
void mirror(int t[], int start,int end)
{
if(start<end)
{
exchange(t+start,t+end);
mirror(t,start+1,end-1);
}
}
Back to the list of exercises
Looking for a more challenging exercise, try this one !!
2 players Game - version 2