Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
#include
using namespace std; const int max_size = 1000; struct magacin { int idx; int niza[max_size]; void init() { idx = -1; } bool isEmpty() { if(idx == -1) { return true; } else { return false; } } bool isFull() { if(idx == max_size - 1) { return true; } else { return false; } } int size() { return idx + 1; } void push(int element) { if(isFull()) { cout << "Nema poveke mesto za elementi" << endl; return; } idx++; niza[idx] = element; } void pop() { if(isEmpty()) { cout << "Stekot e prazen" << endl; return; } idx--; } int top() { if(isEmpty()) { cout << "Nema elementi vo stekot" << endl; return -1; } return niza[idx]; } }; int main() { magacin st; st.init(); st.push(1); st.push(2); st.push(3); cout << st.top() << endl; st.pop(); cout << st.top() << endl; st.pop(); cout << st.top() << endl; return 0; }
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)