#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 | #64566432 | Utilizator | |
| Fișier | fadcresc.cpp | Dimensiune | 781 B |
| Data încărcării | 14 Mai 2026, 16:51 | Scor/rezultat | Eroare de compilare |
fadcresc.cpp:14:8: error: redefinition of ‘struct nod’ 14 | 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:24:11: error: cannot convert ‘nod*’ to ‘int*’ in assignment 24 | q=new nod; | ^~~~~~~ | | | nod* fadcresc.cpp:25:12: error: request for member ‘info’ in ‘* q’, which is of non-class type ‘int’ 25 | q->info=x; | ^~~~ fadcresc.cpp:26:12: error: request for member ‘urm’ in ‘* q’, which is of non-class type ‘int’ 26 | q->urm=q; | ^~~ fadcresc.cpp:27:11: error: cannot convert ‘int*’ to ‘nod*’ in assignment 27 | j=q; | ^ | | | int* fadcresc.cpp:35:8: error: cannot convert ‘nod*’ to ‘int*’ in assignment 35 | q= new nod; | ^~~~~~~ | | | nod* fadcresc.cpp:36:8: error: request for member ‘info’ in ‘* q’, which is of non-class type ‘int’ 36 | q->info=x; | ^~~~ fadcresc.cpp:37:8: error: request for member ‘urm’ in ‘* q’, which is of non-class type ‘int’ 37 | q->urm=j->urm; | ^~~ fadcresc.cpp:38:12: error: cannot convert ‘int*’ to ‘nod*’ in assignment 38 | j->urm=q; | ^ | | | int* fadcresc.cpp: In function ‘int main()’: fadcresc.cpp:52:9: error: cannot convert ‘nod*’ to ‘int*’ in assignment 52 | prim=new nod; | ^~~~~~~ | | | nod* fadcresc.cpp:53:10: error: request for member ‘info’ in ‘* prim’, which is of non-class type ‘int’ 53 | prim->info=x; | ^~~~ fadcresc.cpp:54:10: error: request for member ‘urm’ in ‘* prim’, which is of non-class type ‘int’ 54 | prim->urm=NULL; | ^~~ fadcresc.cpp:57:15: error: invalid initialization of reference of type ‘nod*&’ from expression of type ‘int*’ 57 | 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:59:10: error: cannot convert ‘int*’ to ‘nod*’ 59 | afisare (prim); | ^~~~ | | | int* fadcresc.cpp:40:19: note: initializing argument 1 of ‘void afisare(nod*)’ 40 | void afisare(nod *p) | ~~~~~^ fadcresc.cpp: At global scope: fadcresc.cpp:63:6: error: redefinition of ‘void afisare(nod*)’ 63 | void afisare(nod * p) | ^~~~~~~ fadcresc.cpp:40:6: note: ‘void afisare(nod*)’ previously defined here 40 | void afisare(nod *p) | ^~~~~~~ fadcresc.cpp:95:5: error: redefinition of ‘int main()’ 95 | int main() | ^~~~ fadcresc.cpp:48:5: note: ‘int main()’ previously defined here 48 | 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ă.