Rating changes for last rounds are temporarily rolled back. They will be returned soon. ×

babaslavkavelikata's blog

By babaslavkavelikata, history, 9 years ago, In English

include

using namespace std; void hanoi(int n,int A,int C,int B) { if (n==1) { cout<<n<<" "<<A<<" "<<C<<endl; } else { hanoi(n-1,A,B,C); cout<<n<<" "<<A<<" "<<C<<endl; hanoi(n-1,B,C,A); }

} int main() { int n; cin>>n; hanoi(n,1,3,2); return 0; }

| Write comment?