#673
DifSub
Se dă un arbore binar care conține valori numere naturale. Să se determine diferența în valoare absolută a sumei valorilor memorate în subarborele stâng al rădăcinii și suma valorilor memorate în subarborele drept al rădăcinii.
Problema | DifSub | Operații I/O |
difsub.in /difsub.out
|
---|---|---|---|
Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
Id soluție | #54426244 | Utilizator | |
Fișier | difsub.cpp | Dimensiune | 648 B |
Data încărcării | 28 Noiembrie 2024, 09:46 | Scor / rezultat | Eroare de compilare |
difsub.cpp:6:1: error: expected ',' or ';' before 'ofstream' ofstream cout("difsub.out") ^ difsub.cpp: In function 'int suma(int)': difsub.cpp:13:12: error: 'val' was not declared in this scope return val[nod]+suma(st[nod])+suma(dr[nod]); ^ difsub.cpp:13:26: error: 'st' was not declared in this scope return val[nod]+suma(st[nod])+suma(dr[nod]); ^ difsub.cpp:13:40: error: 'dr' was not declared in this scope return val[nod]+suma(st[nod])+suma(dr[nod]); ^ difsub.cpp: In function 'int main()': difsub.cpp:23:14: error: 'val' was not declared in this scope cin>>val[i]>>st[i]>>dr[i]; ^ difsub.cpp:23:22: error: 'st' was not declared in this scope cin>>val[i]>>st[i]>>dr[i]; ^ difsub.cpp:23:29: error: 'dr' was not declared in this scope cin>>val[i]>>st[i]>>dr[i]; ^ difsub.cpp:24:9: error: 'root' was not declared in this scope root[dr[i]]=root[st[i]]=1; ^ difsub.cpp:28:8: error: 'root' was not declared in this scope if(root[i]==0) ^ difsub.cpp:29:9: error: 'roots' was not declared in this scope roots=i; ^ difsub.cpp:30:21: error: 'st' was not declared in this scope int sumast=suma(st[roots]); ^ difsub.cpp:30:24: error: 'roots' was not declared in this scope int sumast=suma(st[roots]); ^ difsub.cpp:31:21: error: 'dr' was not declared in this scope int sumadr=suma(dr[roots]); ^ difsub.cpp:36:5: error: 'cout' was not declared in this scope cout<<diff; ^ difsub.cpp: In function 'int suma(int)': difsub.cpp:14:1: warning: control reaches end of non-void function [-Wreturn-type] } ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema DifSub 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ă.