#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 | #64820066 | Utilizator | |
| Fișier | stiva.cpp | Dimensiune | 566 B |
| Data încărcării | 03 Iunie 2026, 15:05 | Scor/rezultat | Eroare de compilare |
stiva.cpp:8:9: error: field ‘urm’ has incomplete type ‘nod’ 8 | nod urm; | ^~~ stiva.cpp:5:8: note: definition of ‘struct nod’ is not complete until the closing brace 5 | struct nod | ^~~ stiva.cpp:10:7: error: expected initializer before ‘<’ token 10 | stack <int>S; | ^ stiva.cpp: In function ‘int main()’: stiva.cpp:36:23: error: expected ‘)’ at end of input 36 | else if(strcmp | ~ ^ | ) stiva.cpp:36:17: warning: the address of ‘int strcmp(const char*, const char*)’ will never be NULL [-Waddress] 36 | else if(strcmp | ^~~~~~ In file included from /usr/include/c++/13/cstring:42, from stiva.cpp:2: /usr/include/string.h:156:12: note: ‘int strcmp(const char*, const char*)’ declared here 156 | extern int strcmp (const char *__s1, const char *__s2) | ^~~~~~ stiva.cpp:36:23: error: expected statement at end of input 36 | else if(strcmp | ^ stiva.cpp:36:9: warning: this ‘else’ clause does not guard... [-Wmisleading-indentation] 36 | else if(strcmp | ^~~~ stiva.cpp:36:23: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘else’ 36 | else if(strcmp | ^ stiva.cpp:36:23: error: expected ‘}’ at end of input stiva.cpp:21:5: note: to match this ‘{’ 21 | { | ^ stiva.cpp:36:23: error: expected ‘}’ at end of input 36 | else if(strcmp | ^ stiva.cpp:13:1: note: to match this ‘{’ 13 | { | ^ stiva.cpp:14:13: warning: unused variable ‘k’ [-Wunused-variable] 14 | int n,x,k=0; | ^
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ă.