#include <iostream>
using namespace std;
void TOH(int n, int a, int b, int c)
{
if(n>0)
{
TOH(n-1,a,c,b);
cout << "from " << a << " to " << c <<endl;
TOH(n-1,b,a,c);
}
}
int main()
{
TOH(6,1,2,3);
return 0;
}
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter