i need help guys im stuck

Hey guys im experimenting on void recursive function,
and i dont understand why the ouput of this program is
{1 2 1 3 1 2 1 }
because the next number to 3 is 2 and then 1
so the output should be {1 2 3 2 1}
please help! i dont understand ;

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
int main(void)
{
	int x=3;
	hanoi(x);
}
void hanoi(int x)
{
	if(x==1) {
		cout<<x<<" ";
	}
	else 
	{	
		hanoi(x-1);
		cout<<x<<" ";
		hanoi(x-1);
	}	
}
Last edited on
Topic archived. No new replies allowed.