#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 | #63504412 | Utilizator | |
| Fișier | stiva.cpp | Dimensiune | 605 B |
| Data încărcării | 06 Martie 2026, 08:47 | Scor/rezultat | Eroare de compilare |
stiva.cpp:2:2: error: invalid preprocessing directive #inlude #inlude<string.h> ^ stiva.cpp: In function 'int main()': stiva.cpp:12:9: warning: 'char* gets(char*)' is deprecated (declared at /usr/include/stdio.h:638) [-Wdeprecated-declarations] gets(sir); ^ stiva.cpp:12:17: warning: 'char* gets(char*)' is deprecated (declared at /usr/include/stdio.h:638) [-Wdeprecated-declarations] gets(sir); ^ stiva.cpp:13:28: error: 'strstr' was not declared in this scope p=strstr(sir,"push"); ^ stiva.cpp:16:29: error: 'strchr' was not declared in this scope q=strchr(sir,' '); ^ stiva.cpp:17:20: error: 'nr' was not declared in this scope strcpy(nr,q+1); ^ stiva.cpp:17:26: error: 'strcpy' was not declared in this scope strcpy(nr,q+1); ^ stiva.cpp:26:9: error: 'i' was not declared in this scope for(i=1;i<=k;i++) ^ stiva.cpp:28:9: error: 'retunr' was not declared in this scope retunr ^ stiva.cpp:29:1: error: expected ';' before '}' token } ^ stiva.cpp:8:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result] scanf("%d",&n); ^ stiva.cpp:9:19: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result] scanf("%c",&e); ^ stiva.cpp:12:18: warning: ignoring return value of 'char* gets(char*)', declared with attribute warn_unused_result [-Wunused-result] gets(sir); ^
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ă.