#756
Se consideră un arbore binar în care nodurile memorează numere naturale nenule. Să se determine câte noduri din arbore au un singur descendent direct.
Programul citește lista valorilor din arbore, dată în ordinea parcurgerii în preordine.
| Problema | NrNod | Operații I/O |
nrnod.in/nrnod.out
|
|---|---|---|---|
| Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
| Id soluție | #64745617 | Utilizator | |
| Fișier | nrnod.cpp | Dimensiune | 862 B |
| Data încărcării | 27 Mai 2026, 13:06 | Scor/rezultat | Eroare de compilare |
nrnod.cpp: In function ‘void creare(nod**, int)’: nrnod.cpp:11:11: error: cannot convert ‘ref’ {aka ‘nod*’} to ‘nod**’ in assignment 11 | r=(ref)malloc(sizeof(struct nod)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | ref {aka nod*} nrnod.cpp:12:12: error: request for member ‘inf’ in ‘* r’, which is of pointer type ‘ref’ {aka ‘nod*’} (maybe you meant to use ‘->’ ?) 12 | r->inf=x; | ^~~ nrnod.cpp:13:12: error: request for member ‘st’ in ‘* r’, which is of pointer type ‘ref’ {aka ‘nod*’} (maybe you meant to use ‘->’ ?) 13 | r->st =r->dr=NULL; | ^~ nrnod.cpp:13:19: error: request for member ‘dr’ in ‘* r’, which is of pointer type ‘ref’ {aka ‘nod*’} (maybe you meant to use ‘->’ ?) 13 | r->st =r->dr=NULL; | ^~ nrnod.cpp:16:19: error: request for member ‘st’ in ‘* r’, which is of pointer type ‘ref’ {aka ‘nod*’} (maybe you meant to use ‘->’ ?) 16 | creare(r->st,y); | ^~ nrnod.cpp:18:19: error: request for member ‘dr’ in ‘* r’, which is of pointer type ‘ref’ {aka ‘nod*’} (maybe you meant to use ‘->’ ?) 18 | creare(r->dr,y); | ^~ nrnod.cpp:15:15: warning: ignoring return value of ‘int fscanf(FILE*, const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 15 | fscanf(f,"%d",&y); | ~~~~~~^~~~~~~~~~~ nrnod.cpp:17:15: warning: ignoring return value of ‘int fscanf(FILE*, const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 17 | fscanf(f,"%d",&y); | ~~~~~~^~~~~~~~~~~ nrnod.cpp: In function ‘int main()’: nrnod.cpp:37:11: warning: ignoring return value of ‘int fscanf(FILE*, const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 37 | fscanf(f,"%d",&x); | ~~~~~~^~~~~~~~~~~
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema NrNod 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ă.