#4682
Să se scrie funcția Erase
care va șterge dintr-o listă dublu înlănțuită toate nodurile care memorează numere pare. De exemplu, dacă lista reține valorile 5,3,6,2,1,8
, atunci după apelul Erase(prim, ultim)
, lista va fi 5,3,1
.
Problema | FLdiErase | Operații I/O |
![]() erase.in /erase.out
|
---|---|---|---|
Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
Id soluție | #58337090 | Utilizator | |
Fișier | fldierase.cpp | Dimensiune | 1.89 KB |
Data încărcării | 27 Mai 2025, 23:39 | Scor / rezultat | Eroare de compilare |
fldierase.cpp:17:8: error: redefinition of 'struct nod' struct nod ^ fldierase.cpp:4:8: error: previous definition of 'struct nod' struct nod ^ fldierase.cpp:21:8: error: invalid type in declaration before ',' token } *prim, *p, *ultim, *r, *t; ^ fldierase.cpp: In function 'void create()': fldierase.cpp:26:14: error: no matching function for call to 'nod::nod()' prim=new nod; ^ fldierase.cpp:26:14: note: candidates are: fldierase.cpp:8:5: note: nod::nod(int) nod(int x) ^ fldierase.cpp:8:5: note: candidate expects 1 argument, 0 provided fldierase.cpp:4:8: note: constexpr nod::nod(const nod&) struct nod ^ fldierase.cpp:4:8: note: candidate expects 1 argument, 0 provided fldierase.cpp:4:8: note: constexpr nod::nod(nod&&) fldierase.cpp:4:8: note: candidate expects 1 argument, 0 provided fldierase.cpp:28:16: error: request for member 'info' in '* prim', which is of non-class type 'int' cin>>prim->info; ^ fldierase.cpp:29:11: error: request for member 'urm' in '* prim', which is of non-class type 'int' prim->urm=NULL; ^ fldierase.cpp:32:15: error: no matching function for call to 'nod::nod()' p=new nod; ^ fldierase.cpp:32:15: note: candidates are: fldierase.cpp:8:5: note: nod::nod(int) nod(int x) ^ fldierase.cpp:8:5: note: candidate expects 1 argument, 0 provided fldierase.cpp:4:8: note: constexpr nod::nod(const nod&) struct nod ^ fldierase.cpp:4:8: note: candidate expects 1 argument, 0 provided fldierase.cpp:4:8: note: constexpr nod::nod(nod&&) fldierase.cpp:4:8: note: candidate expects 1 argument, 0 provided fldierase.cpp:33:17: error: request for member 'info' in '* p', which is of non-class type 'int' cin>>p->info; ^ fldierase.cpp:34:12: error: request for member 'urm' in '* p', which is of non-class type 'int' p->urm=NULL; ^ fldierase.cpp:35:16: error: request for member 'urm' in '* ultim', which is of non-class type 'int' ultim->urm=p; ^ fldierase.cpp: In function 'void afisare()': fldierase.cpp:44:18: error: request for member 'info' in '* p', which is of non-class type 'int' cout<<p->info<<" "; ^ fldierase.cpp:45:14: error: request for member 'urm' in '* p', which is of non-class type 'int' p=p->urm; ^ fldierase.cpp: In function 'void sort_descrescator()': fldierase.cpp:50:16: error: cannot convert 'int*' to 'nod*' in initialization for(nod *i=prim;i!=NULL;i=i->urm) ^ fldierase.cpp: In function 'void inserare_descrescator(int)': fldierase.cpp:65:18: error: no matching function for call to 'nod::nod()' nod *nou=new nod; ^ fldierase.cpp:65:18: note: candidates are: fldierase.cpp:8:5: note: nod::nod(int) nod(int x) ^ fldierase.cpp:8:5: note: candidate expects 1 argument, 0 provided fldierase.cpp:4:8: note: constexpr nod::nod(const nod&) struct nod ^ fldierase.cpp:4:8: note: candidate expects 1 argument, 0 provided fldierase.cpp:4:8: note: constexpr nod::nod(nod&&) fldierase.cpp:4:8: note: candidate expects 1 argument, 0 provided fldierase.cpp:68:33: error: request for member 'info' in '* prim', which is of non-class type 'int' if (prim==NULL || val>prim->info) ^ fldierase.cpp:70:17: error: cannot convert 'int*' to 'nod*' in assignment nou->urm=prim; ^ fldierase.cpp:71:13: error: cannot convert 'nod*' to 'int*' in assignment prim=nou; ^ fldierase.cpp:74:17: error: cannot convert 'int*' to 'nod*' in initialization nod *curent=prim; ^ fldierase.cpp: In function 'void sterge_ultimul_negativ()': fldierase.cpp:85:17: error: cannot convert 'int*' to 'nod*' in initialization nod *curent=prim; ^ fldierase.cpp:104:20: error: comparison between distinct pointer types 'nod*' and 'int*' lacks a cast [-fpermissive] if (ultim_neg==prim) ^ fldierase.cpp:106:20: error: request for member 'urm' in '* prim', which is of non-class type 'int' prim=prim->urm; ^ fldierase.cpp: In function 'int main()': fldierase.cpp:125:5: error: redefinition of 'int main()' int main() ^ fldierase.cpp:114:5: error: 'int main()' previously defined here int main() ^ fldierase.cpp:146:22: error: 'Erase' was not declared in this scope Erase(prim, ultim); ^
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema FLdiErase 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ă.