#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 | #64802073 | Utilizator | |
| Fișier | stiva.cpp | Dimensiune | 666 B |
| Data încărcării | 02 Iunie 2026, 11:59 | Scor/rezultat | 0 puncte |
stiva.cpp: In function ‘int main()’: stiva.cpp:34:22: warning: the address of ‘int isempty()’ will never be NULL [-Waddress] 34 | else if(!isempty){ | ^~~~~~~ stiva.cpp:16:5: note: ‘int isempty()’ declared here 16 | int isempty(){ | ^~~~~~~ stiva.cpp:26:18: warning: ‘comm’ may be used uninitialized [-Wmaybe-uninitialized] 26 | if(strcmp(comm,"push")==0){ | ~~~~~~^~~~~~~~~~~~~ In file included from /usr/include/c++/13/cstring:42, from stiva.cpp:2: /usr/include/string.h:156:12: note: by argument 1 of type ‘const char*’ to ‘int strcmp(const char*, const char*)’ declared here 156 | extern int strcmp (const char *__s1, const char *__s2) | ^~~~~~ stiva.cpp:22:10: note: ‘comm’ declared here 22 | char comm[5]; | ^~~~ stiva.cpp:30:23: warning: ‘comm’ may be used uninitialized [-Wmaybe-uninitialized] 30 | else if(strcmp(comm,"pop")==0){ | ~~~~~~^~~~~~~~~~~~ <built-in>: note: by argument 1 of type ‘const void*’ to ‘int __builtin_strcmp_eq(const void*, const void*, long unsigned int)’ declared here stiva.cpp:22:10: note: ‘comm’ declared here 22 | char comm[5]; | ^~~~
| Test | Timp | Mesaj evaluare | Scor posibil | Scor obținut | ||
|---|---|---|---|---|---|---|
| 1 | 0.001 secunde | Raspuns gresit. | 20 | 0 | Exemplu | |
| 2 | 0.001 secunde | Raspuns gresit. | 20 | 0 | ||
| 3 | 0.001 secunde | Raspuns gresit. | 20 | 0 | ||
| 4 | 0.001 secunde | Raspuns gresit. | 20 | 0 | ||
| 5 | 0.001 secunde | Raspuns gresit. | 20 | 0 | ||
| Punctaj total | 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ă.