Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- int move(int n,int x,int y)
- {
- int z;
- if (x==1)
- {
- if (y==2) z=3;
- else z=2;
- }
- else
- if (x==2)
- {
- if (y==1) z=3;
- else z=1;
- }
- else
- {
- if (y==1) z=2;
- else z=1;
- }
- if (n==0) return 0;
- else
- if (n==1) cout<<n<<" "<<x<<" "<<y<<endl;
- else
- if (n>=1)
- {
- move(n-1,x,z);
- cout<<n<<" "<<x<<" "<<y<<endl;
- move(n-1,z,y);
- }
- }
- int main()
- {
- int n,x,y;
- cin>>n>>x>>y;
- move(n,x,y);
- return 0;
- }
Add Comment
Please, Sign In to add comment