#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 | #64817895 | Utilizator | |
| Fișier | stiva.cpp | Dimensiune | 745 B |
| Data încărcării | 03 Iunie 2026, 12:51 | Scor/rezultat | Eroare de compilare |
stiva.cpp:6:9: error: expected ‘;’ at end of member declaration 6 | nod*urm} *vf; | ^~~ | ; stiva.cpp: In function ‘void push(nod*&, int)’: stiva.cpp:18:8: warning: init-statement in selection statements only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions] 18 | if(esteVida(vf); | ^~~~~~~~ stiva.cpp:18:8: error: ‘esteVida’ was not declared in this scope stiva.cpp:19:14: error: expected ‘)’ before ‘;’ token 19 | vf=nou; | ^ | ) stiva.cpp:18:7: note: to match this ‘(’ 18 | if(esteVida(vf); | ^ stiva.cpp:19:10: warning: suggest parentheses around assignment used as truth value [-Wparentheses] 19 | vf=nou; | ~~^~~~ stiva.cpp: In function ‘int top(nod*)’: stiva.cpp:39:8: warning: no return statement in function returning non-void [-Wreturn-type] 39 | } | ^ stiva.cpp: In function ‘int main()’: stiva.cpp:44:27: error: expected statement at end of input 44 | for(int i=0; i<n; i++) | ^ stiva.cpp:44:27: error: expected ‘}’ at end of input stiva.cpp:41:1: note: to match this ‘{’ 41 | { | ^
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ă.