void recursive program that reverses a sentence
Ok I am a new programmer and i am absolutly clueless when it comes to changing strings for some reason i need to:
Write a recursive methood void reverse() that reverses a sentence, and it must remove the first character, reverse a sentence consisting of the remaining text then combine the two and print it an explination of how it works would be very helpful too
I CANT FIGURE IT OUT AND I AM PANICKING :crybaby:
Re: void recursive program that reverses a sentence
Since its a homework question, I would be providing some points below:
- Using a reference is simpler than using pointers
- You really need to increase the result, not set it to 0 or 1. Therefore you need to pass to first function call by reference an int with assigned value of 0.
- Consider the formula: f(n) = f(n-1) + f(n-2) for all n > 2; f(n) = 0 for n=1 and f(n) = 1 for n=2.