Pagini recente » Cod sursa (job #951129) | Cod sursa (job #2556421) | Cod sursa (job #1764470) | Cod sursa (job #1413014) | Cod sursa (job #2083220)
#include<fstream>
using namespace std;
ifstream fin("hanoi.in");
ofstream fout("hanoi.out");
int n, S, S1;
void solve( int nr, int a, int b, int aux ){
//sa mut primele nr discuri de pe a pe b flosind aux
if( nr == 1 )
return;
solve( )
}
int main(){
fin >> n;
for( int i = 1; i <= n; i++ ){
if( i % 2 == 1 ){
solve( i * 2 - 2, 1, 3, 2 );
fout << "1 2\n";
solve( i * 2 - 2, 3, 2, 1 );
}else{
solve( i * 2 - 2, 2, 3, 1 );
fout << "2 1\n";
solve( i * 2 - 2, 3, 1, 2 );
}
}
if( n % 2 == 0 )
S = 1;
else
S = 2;
S1 = 3 - S;
for( int i = 1, cnt = 2 * n - 2; i < n; i++, cnt -= 2 ){
solve( cnt, 3, S, S1 );
fout << S << " " << S1 << "\n";
solve( cnt, 3, S, S1 );
}
fout << "0\n";
return 0;
}