#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 | #63504418 | Utilizator | |
| Fișier | stiva.cpp | Dimensiune | 762 B |
| Data încărcării | 06 Martie 2026, 08:47 | Scor/rezultat | Eroare de compilare |
stiva.cpp:1:2: error: invalid preprocessing directive #inclde #inclde<stdio.h> ^ stiva.cpp:3:9: error: #include expects "FILENAME" or <FILENAME> #include ^ stiva.cpp: In function 'int main()': stiva.cpp:7:18: warning: overflow in implicit constant conversion [-Woverflow] char sir(1000),e,*p,*q; ^ stiva.cpp:8:18: error: 'scanf' was not declared in this scope scanf("%d",&n); ^ stiva.cpp:12:21: error: 'gets' was not declared in this scope gets(sir); ^ stiva.cpp:13:32: error: 'strsrt' was not declared in this scope p=strsrt(sir,"push"); ^ stiva.cpp:16:33: error: call of overloaded 'strchr(char&, char)' is ambiguous q=strchr(sir,' '); ^ stiva.cpp:16:33: note: candidates are: In file included from stiva.cpp:2:0: /usr/include/string.h:223:1: note: char* strchr(char*, int) <near match> strchr (char *__s, int __c) __THROW ^ /usr/include/string.h:223:1: note: no known conversion for argument 1 from 'char' to 'char*' /usr/include/string.h:229:1: note: const char* strchr(const char*, int) <near match> strchr (const char *__s, int __c) __THROW ^ /usr/include/string.h:229:1: note: no known conversion for argument 1 from 'char' to 'const char*' stiva.cpp:17:24: error: 'nr' was not declared in this scope strcpy(nr,q+1); ^ stiva.cpp:19:30: error: 'stoi' was not declared in this scope s[vf]=stoi(nr); ^ stiva.cpp:22:36: error: call of overloaded 'strstr(char&, const char [4])' is ambiguous if(strstr(sir,"pop")!=NULL) ^ stiva.cpp:22:36: note: candidates are: In file included from stiva.cpp:2:0: /usr/include/string.h:329:1: note: char* strstr(char*, const char*) <near match> strstr (char *__haystack, const char *__needle) __THROW ^ /usr/include/string.h:329:1: note: no known conversion for argument 1 from 'char' to 'char*' /usr/include/string.h:335:1: note: const char* strstr(const char*, const char*) <near match> strstr (const char *__haystack, const char *__needle) __THROW ^ /usr/include/string.h:335:1: note: no known conversion for argument 1 from 'char' to 'const char*' stiva.cpp:29:18: error: 'k' was not declared in this scope k++;v[k]=s[vf]; ^ stiva.cpp:29:22: error: 'v' was not declared in this scope k++;v[k]=s[vf]; ^ stiva.cpp:31:29: error: 'k' was not declared in this scope for(int i=1;i<=k;i++) ^ stiva.cpp:32:30: error: 'v' was not declared in this scope printf("%\n",v[i]); ^ stiva.cpp:32:34: error: 'printf' was not declared in this scope printf("%\n",v[i]); ^ stiva.cpp:34:9: error: expected '}' at end of input } ^
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ă.