#670
Se dă un arbore binar care conține valori numere naturale. Să se afișeze valorile din arbore în urma parcurgerii în preordine.
Notă: pentru reprezentarea arborelui se recomandă alocarea statică, folosind tablouri.
| Problema | Preordine | Operații I/O |
preordine.in/preordine.out
|
|---|---|---|---|
| Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
| Id soluție | #64441260 | Utilizator | |
| Fișier | preordine.cpp | Dimensiune | 539 B |
| Data încărcării | 07 Mai 2026, 09:31 | Scor/rezultat | Eroare de compilare |
preordine.cpp:6:1: error: expected ‘,’ or ‘;’ before ‘ofstream’ 6 | ofstream out("preordine.out") | ^~~~~~~~ preordine.cpp: In function ‘void afis(int)’: preordine.cpp:10:5: error: ‘out’ was not declared in this scope 10 | out<<x[k]<<" "; | ^~~ preordine.cpp:10:10: error: ‘x’ was not declared in this scope 10 | out<<x[k]<<" "; | ^ preordine.cpp:11:8: error: ‘s’ was not declared in this scope 11 | if(s[k]!=0) | ^ preordine.cpp:11:5: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation] 11 | if(s[k]!=0) | ^~ preordine.cpp:13:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’ 13 | if(d[k]!=0) | ^~ preordine.cpp:13:12: error: ‘d’ was not declared in this scope 13 | if(d[k]!=0) | ^ preordine.cpp: In function ‘int main()’: preordine.cpp:18:9: error: ‘n’ was not declared in this scope; did you mean ‘in’? 18 | in>>n; | ^ | in preordine.cpp:22:13: error: ‘x’ was not declared in this scope 22 | in>>x[i]>>s[i]>>d[i]; | ^ preordine.cpp:22:19: error: ‘s’ was not declared in this scope 22 | in>>x[i]>>s[i]>>d[i]; | ^ preordine.cpp:22:25: error: ‘d’ was not declared in this scope 22 | in>>x[i]>>s[i]>>d[i]; | ^ preordine.cpp:23:9: error: ‘t’ was not declared in this scope 23 | t[s[i]]=t[d[i]]=i; | ^ preordine.cpp:25:9: error: ‘i’ was not declared in this scope 25 | for(i=1; i<=n; i++) | ^ preordine.cpp:26:12: error: ‘t’ was not declared in this scope 26 | if(t[i]==0) | ^ preordine.cpp:27:13: error: ‘r’ was not declared in this scope 27 | r=i; | ^ preordine.cpp:28:10: error: ‘r’ was not declared in this scope 28 | afis(r); | ^ preordine.cpp:19:9: warning: unused variable ‘v’ [-Wunused-variable] 19 | int v,w,u; | ^ preordine.cpp:19:11: warning: unused variable ‘w’ [-Wunused-variable] 19 | int v,w,u; | ^ preordine.cpp:19:13: warning: unused variable ‘u’ [-Wunused-variable] 19 | int v,w,u; | ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Preordine 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ă.