Untitled

mail@pastecode.io avatar
unknown
c_cpp
2 years ago
348 B
9
Indexable
Never
#include <bits/stdc++.h>
using namespace std;
void h(int n,int i, int j)
{
    if(n==1) cout<<1<<' '<<i<<' '<<j<<endl;
     else
     { int k;
         if(i*j==2)k=3;
         if(i*j==3)k=2;
         if(i*j==6)k=1;
         h(n-1,i,k);
         cout<<n<<' '<<i<<' '<<j<<endl;
         h(n-1,k,j);
     }
}
int main()
{
 int n;
 cin>>n;
 h(n,1,3);
}