#875
Să se scrie un program care gestionează o stivă de numere întregi. Inițial stiva este vidă. Programul va citi de la tastatură o listă de operații, care pot fi:
push X – adaugă valoarea întreagă X pe stivă;pop – elimină elementul din vârful stivei;top – afișează elementul din vârful stivei.Programul va realiza asupra stivei operațiile citite, în ordine. Afișările se fac pe ecran, câte o valoare pe linie.
| Problema | Stiva | Operații I/O |
tastatură/ecran
|
|---|---|---|---|
| Limita timp | 0.1 secunde | Limita memorie |
Total: 64 MB
/
Stivă 8 MB
|
| Id soluție | #64817947 | Utilizator | |
| Fișier | stiva.cpp | Dimensiune | 702 B |
| Data încărcării | 03 Iunie 2026, 12:53 | Scor/rezultat | Eroare de compilare |
stiva.cpp:6:1: error: ‘npd’ does not name a type; did you mean ‘nod’? 6 | npd *urm} *vf; | ^~~ | nod stiva.cpp: In function ‘void push(nod*&, int)’: stiva.cpp:18:10: error: ‘struct nod’ has no member named ‘urm’ 18 | nou->urm=NULL; | ^~~ stiva.cpp:23:18: error: ‘struct nod’ has no member named ‘urm’ 23 | nou->urm=vf; | ^~~ stiva.cpp: In function ‘void pop(nod*&)’: stiva.cpp:32:16: error: ‘struct nod’ has no member named ‘urm’ 32 | vf=vf->urm; | ^~~ stiva.cpp: In function ‘int top(nod*)’: stiva.cpp:40:1: warning: no return statement in function returning non-void [-Wreturn-type] 40 | } | ^ stiva.cpp: In function ‘int main()’: stiva.cpp:45:1: warning: this ‘for’ clause does not guard... [-Wmisleading-indentation] 45 | for(int i=1;i<=n;i++) | ^~~ stiva.cpp:49:3: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘for’ 49 | push() | ^~~~ stiva.cpp:49:7: error: too few arguments to function ‘void push(nod*&, int)’ 49 | push() | ~~~~^~ stiva.cpp:14:6: note: declared here 14 | void push(nod*&vf,int x) | ^~~~
www.pbinfo.ro permite evaluarea a două tipuri de probleme:
Problema Stiva 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ă.