#2527
Turnurile din Hanoi este un joc matematic sau, dacă vreți, un puzzle. Este format din trei tije A, B și C și un număr variabil de discuri, de diferite diametre. Inițial discurile sunt așezate în ordine descrescătoare a diametrelor pe tija A, de la vârf către bază, astfel încât să formeze un turn.
Scopul jocului este acela de a muta toate discurile de pe tija A pe tija C folosind ca tijă intermediară tija B, respectând următoarele reguli:
Cerința
Dacă se cunoaște numărul n de discuri aflate pe tija A, să se determine șirul mutărilor necesare pentru ca toate discurile să fie mutate pe tija C.
| Problema | hanoi | Operații I/O |
hanoi.in/hanoi.out
|
|---|---|---|---|
| Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
| Id soluție | #64280958 | Utilizator | |
| Fișier | hanoi.cpp | Dimensiune | 514 B |
| Data încărcării | 27 Aprilie 2026, 20:05 | Scor/rezultat | Eroare de compilare |
hanoi.cpp:4:12: error: extended character “ is not valid in an identifier 4 | ifstream f(“hanoi.in”); | ^ hanoi.cpp:4:19: error: extended character ” is not valid in an identifier 4 | ifstream f(“hanoi.in”); | ^ hanoi.cpp:5:12: error: extended character “ is not valid in an identifier 5 | ofstream g(“hanoi.out”); | ^ hanoi.cpp:5:19: error: extended character ” is not valid in an identifier 5 | ofstream g(“hanoi.out”); | ^ hanoi.cpp:10:15: error: extended character “ is not valid in an identifier 10 | g<<x<<“->”<<z<<endl; | ^ hanoi.cpp:10:18: error: extended character ” is not valid in an identifier 10 | g<<x<<“->”<<z<<endl; | ^ hanoi.cpp:14:15: error: extended character “ is not valid in an identifier 14 | g<<x<<“->”<<z<<endl; | ^ hanoi.cpp:14:18: error: extended character ” is not valid in an identifier 14 | g<<x<<“->”<<z<<endl; | ^ hanoi.cpp:27:13: error: extended character ’ is not valid in an identifier 27 | hanoi(n,’A’,’B’,’C’); | ^ hanoi.cpp:27:13: error: extended character ’ is not valid in an identifier hanoi.cpp:27:17: error: extended character ’ is not valid in an identifier 27 | hanoi(n,’A’,’B’,’C’); | ^ hanoi.cpp:27:17: error: extended character ’ is not valid in an identifier hanoi.cpp:27:21: error: extended character ’ is not valid in an identifier 27 | hanoi(n,’A’,’B’,’C’); | ^ hanoi.cpp:27:21: error: extended character ’ is not valid in an identifier hanoi.cpp:4:12: error: ‘“hanoi’ was not declared in this scope 4 | ifstream f(“hanoi.in”); | ^~~~~~ hanoi.cpp:5:12: error: ‘“hanoi’ was not declared in this scope 5 | ofstream g(“hanoi.out”); | ^~~~~~ hanoi.cpp: In function ‘void hanoi(int, char, char, char)’: hanoi.cpp:10:15: error: ‘“’ was not declared in this scope 10 | g<<x<<“->”<<z<<endl; | ^ hanoi.cpp:14:15: error: ‘“’ was not declared in this scope 14 | g<<x<<“->”<<z<<endl; | ^ hanoi.cpp: In function ‘int main()’: hanoi.cpp:27:13: error: ‘’A’’ was not declared in this scope 27 | hanoi(n,’A’,’B’,’C’); | ^~~ hanoi.cpp:27:17: error: ‘’B’’ was not declared in this scope 27 | hanoi(n,’A’,’B’,’C’); | ^~~ hanoi.cpp:27:21: error: ‘’C’’ was not declared in this scope 27 | hanoi(n,’A’,’B’,’C’); | ^~~
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema hanoi face parte din prima categorie. Soluția propusă de tine va fi evaluată astfel:
Suma punctajelor acordate pe testele utilizate pentru verificare este 100. Astfel, soluția ta poate obține cel mult 100 de puncte, caz în care se poate considera corectă.