#4683
Să se scrie o funcție ce va crea o listă simplu înlănțuită care să memoreze în nodurile sale cele n numere întregi din vector, în ordinea în care se află în a. Pointerul head va memora în final adresa primului nod din listă.
| Problema | FLsiMakeList | Operații I/O |
flsimakelist.in/flsimakelist.out
|
|---|---|---|---|
| Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
| Id soluție | #64643899 | Utilizator | |
| Fișier | flsimakelist.cpp | Dimensiune | 515 B |
| Data încărcării | 20 Mai 2026, 09:50 | Scor/rezultat | Eroare de compilare |
flsimakelist.cpp:17:8: error: redefinition of ‘struct nod’ 17 | struct nod { | ^~~ flsimakelist.cpp:4:8: note: previous definition of ‘struct nod’ 4 | struct nod | ^~~ flsimakelist.cpp:22:5: error: conflicting declaration ‘int a [101]’ 22 | int a[101], n; | ^ flsimakelist.cpp:10:5: note: previous declaration as ‘int a [105]’ 10 | int a[105], n; | ^ flsimakelist.cpp:22:13: error: redefinition of ‘int n’ 22 | int a[101], n; | ^ flsimakelist.cpp:10:13: note: ‘int n’ previously declared here 10 | int a[105], n; | ^ In file included from /usr/include/uchar.h:29, from /usr/include/c++/13/cuchar:57, from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:134, from flsimakelist.cpp:1: flsimakelist.cpp: In function ‘void MakeList(nod*&, int*, int)’: flsimakelist.cpp:24:21: error: cannot bind non-const lvalue reference of type ‘nod*&’ to a value of type ‘long int’ 24 | { nod *&ultim=NULL; | ^~~~ flsimakelist.cpp: In function ‘int main()’: flsimakelist.cpp:49:10: error: invalid initialization of reference of type ‘nod*&’ from expression of type ‘int*’ 49 | MakeList(head, a, n) | ^~~~ flsimakelist.cpp:23:21: note: in passing argument 1 of ‘void MakeList(nod*&, int*, int)’ 23 | void MakeList(nod *&head, int a[], int n) | ~~~~~~^~~~ flsimakelist.cpp:51:5: error: ‘p’ was not declared in this scope 51 | for(p=head; p; ) | ^ flsimakelist.cpp: At global scope: flsimakelist.cpp:56:5: error: redefinition of ‘int main()’ 56 | int main() | ^~~~ flsimakelist.cpp:45:5: note: ‘int main()’ previously defined here 45 | int main() | ^~~~
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema FLsiMakeList 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ă.