#2527
hanoi
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 | #54909498 | Utilizator | |
Fișier | hanoi.cpp | Dimensiune | 490 B |
Data încărcării | 11 Decembrie 2024, 22:16 | Scor / rezultat | Eroare de compilare |
hanoi.cpp:4:1: error: stray '\342' in program ifstream fin(“hanoi.in”); ^ hanoi.cpp:4:1: error: stray '\200' in program hanoi.cpp:4:1: error: stray '\234' in program hanoi.cpp:4:1: error: stray '\342' in program hanoi.cpp:4:1: error: stray '\200' in program hanoi.cpp:4:1: error: stray '\235' in program hanoi.cpp:5:1: error: stray '\342' in program ofstream fout(“hanoi.out”); ^ hanoi.cpp:5:1: error: stray '\200' in program hanoi.cpp:5:1: error: stray '\234' in program hanoi.cpp:5:1: error: stray '\342' in program hanoi.cpp:5:1: error: stray '\200' in program hanoi.cpp:5:1: error: stray '\235' in program hanoi.cpp:11:9: error: stray '\342' in program fout<<endl<<A<<“->”<<C; ^ hanoi.cpp:11:9: error: stray '\200' in program hanoi.cpp:11:9: error: stray '\234' in program hanoi.cpp:11:9: error: stray '\342' in program hanoi.cpp:11:9: error: stray '\200' in program hanoi.cpp:11:9: error: stray '\235' in program hanoi.cpp:15:9: error: stray '\342' in program fout<<endl<<A<<“->”<<C; ^ hanoi.cpp:15:9: error: stray '\200' in program hanoi.cpp:15:9: error: stray '\234' in program hanoi.cpp:15:9: error: stray '\342' in program hanoi.cpp:15:9: error: stray '\200' in program hanoi.cpp:15:9: error: stray '\235' in program hanoi.cpp:4:17: error: 'hanoi' was not declared in this scope ifstream fin(“hanoi.in”); ^ hanoi.cpp:5:18: error: 'hanoi' was not declared in this scope ofstream fout(“hanoi.out”); ^ hanoi.cpp:7:23: error: expected ',' or '...' before 'A' void hanoi(int n,char 'A',char 'B',char 'C') ^ hanoi.cpp: In function 'void hanoi(int, char)': hanoi.cpp:11:21: error: 'A' was not declared in this scope fout<<endl<<A<<“->”<<C; ^ hanoi.cpp:11:27: error: expected primary-expression before '->' token fout<<endl<<A<<“->”<<C; ^ hanoi.cpp:11:32: error: expected unqualified-id before '<<' token fout<<endl<<A<<“->”<<C; ^ hanoi.cpp:11:34: error: 'C' was not declared in this scope fout<<endl<<A<<“->”<<C; ^ hanoi.cpp:14:19: error: 'A' was not declared in this scope hanoi(n-1,A,C,B); ^ hanoi.cpp:14:21: error: 'C' was not declared in this scope hanoi(n-1,A,C,B); ^ hanoi.cpp:14:23: error: 'B' was not declared in this scope hanoi(n-1,A,C,B); ^ hanoi.cpp:15:27: error: expected primary-expression before '->' token fout<<endl<<A<<“->”<<C; ^ hanoi.cpp:15:32: error: expected unqualified-id before '<<' token fout<<endl<<A<<“->”<<C; ^ hanoi.cpp: In function 'int main()': hanoi.cpp:25:18: error: too many arguments to function 'void hanoi(int, char)' hanoi(n,a,b,c); ^ hanoi.cpp:7:6: note: declared here void hanoi(int n,char 'A',char 'B',char '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ă.