Cod sursa(job #282703)
Utilizator | Prigoana Cristian cristiprg | Data | 18 martie 2009 08:38:34 |
---|---|---|---|
Problema | Subsir crescator maximal | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.38 kb |
#include <cstdio>
void hanoi(int n, char ts, char ta,char td)
{
if (n == 1)
{
printf ("%c -> %c\n", ts, td);
return ;
}
else
{
hanoi(n-1, ts, td, ta);
hanoi(1, ts, ta, td);
hanoi(n-1, td, ta, ts);
}
}
int main()
{
FILE *f = fopen("ceva.txt", "r");
int n;
fscanf(f, "%d", &n);
fclose(f);
hanoi(n, 'a', 'c', 'b');
return 0;
}