Hello mates!
I'm having quite a bit of trouble reversing a set of integers using recursion.
The user enters a positive integer. The program then takes that integer, and lists 0,1,2...Number originally entered. The function SumTo lists zero to N, however I now need to reverse that list. Like this...
Enter a positive integer: 3
0, 1, 2, 3
3, 2, 1, 0
void SumTo(int Num){
if(Num >= 1)
SumTo(Num -1);
cout << Num << " ";
}
void Reverse(int Num){
SumTo(Num);
if(Num != 0){
Reverse(Num - 1);
cout << Num << " ";
}
Reverse is the reverse function, however it prints like this (although in all one line)
0123
012
01
0
123
Suggestions on how to only print 3 2 1 0?