#2563
Să se scrie o funcție C++ care inserează într-o listă simplu înlănțuită cu elementele ordonate crescător un nou nod care memorează valoarea x astfel încât informațiile din lista să fie în continuare ordonate crescător.
| Problema | FAdCresc | Operații I/O |
tastatură/ecran
|
|---|---|---|---|
| Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
| Id soluție | #64566405 | Utilizator | |
| Fișier | fadcresc.cpp | Dimensiune | 753 B |
| Data încărcării | 14 Mai 2026, 16:50 | Scor/rezultat | Eroare de compilare |
fadcresc.cpp:13:8: error: redefinition of ‘struct nod’ 13 | struct nod | ^~~ fadcresc.cpp:4:8: note: previous definition of ‘struct nod’ 4 | struct nod{ | ^~~ fadcresc.cpp: In function ‘void ins_cresc(nod*&, int)’: fadcresc.cpp:20:14: error: request for member ‘info’ in ‘* prim’, which is of non-class type ‘int’ 20 | if(prim->info>x) | ^~~~ fadcresc.cpp:22:11: error: cannot convert ‘nod*’ to ‘int*’ in assignment 22 | q=new nod; | ^~~~~~~ | | | nod* fadcresc.cpp:23:12: error: request for member ‘info’ in ‘* q’, which is of non-class type ‘int’ 23 | q->info=x; | ^~~~ fadcresc.cpp:24:12: error: request for member ‘urm’ in ‘* q’, which is of non-class type ‘int’ 24 | q->urm=prim; | ^~~ fadcresc.cpp:31:7: error: cannot convert ‘nod*’ to ‘int*’ in assignment 31 | q=new nod; | ^~~~~~~ | | | nod* fadcresc.cpp:32:8: error: request for member ‘info’ in ‘* q’, which is of non-class type ‘int’ 32 | q->info=x; | ^~~~ fadcresc.cpp:33:8: error: request for member ‘urm’ in ‘* q’, which is of non-class type ‘int’ 33 | q->urm=p->urm; | ^~~ fadcresc.cpp:34:12: error: cannot convert ‘int*’ to ‘nod*’ in assignment 34 | p->urm=q; | ^ | | | int* fadcresc.cpp: In function ‘int main()’: fadcresc.cpp:48:10: error: cannot convert ‘nod*’ to ‘int*’ in assignment 48 | prim=new nod; | ^~~~~~~ | | | nod* fadcresc.cpp:49:11: error: request for member ‘info’ in ‘* prim’, which is of non-class type ‘int’ 49 | prim->info=x; | ^~~~ fadcresc.cpp:50:11: error: request for member ‘urm’ in ‘* prim’, which is of non-class type ‘int’ 50 | prim->urm=NULL; | ^~~ fadcresc.cpp:53:19: error: invalid initialization of reference of type ‘nod*&’ from expression of type ‘int*’ 53 | ins_cresc(prim,x); | ^~~~ fadcresc.cpp:18:22: note: in passing argument 1 of ‘void ins_cresc(nod*&, int)’ 18 | void ins_cresc(nod *&p, int x) | ~~~~~~^ fadcresc.cpp:55:13: error: cannot convert ‘int*’ to ‘nod*’ 55 | afisare(prim); | ^~~~ | | | int* fadcresc.cpp:36:19: note: initializing argument 1 of ‘void afisare(nod*)’ 36 | void afisare(nod *p) | ~~~~~^ fadcresc.cpp: At global scope: fadcresc.cpp:58:6: error: redefinition of ‘void afisare(nod*)’ 58 | void afisare(nod * p) | ^~~~~~~ fadcresc.cpp:36:6: note: ‘void afisare(nod*)’ previously defined here 36 | void afisare(nod *p) | ^~~~~~~ fadcresc.cpp:90:5: error: redefinition of ‘int main()’ 90 | int main() | ^~~~ fadcresc.cpp:44:5: note: ‘int main()’ previously defined here 44 | int main() | ^~~~
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema FAdCresc face parte din a doua categorie. Pentru aceste probleme se folosește un program suport, furnizat de propunătorul problemei. 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ă.