Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int const N = 20;
- int stack[N];
- int index = -1;
- bool IsEmpty()
- {
- return(index == -1);
- }
- void Push(int item)
- {
- if(index<N-1)
- {
- index++;
- stack[index] = item;
- }
- else
- {
- cout << "Preteceni" << endl;
- }
- }
- int Top()
- {
- if(!IsEmpty)
- {
- return stack[index];
- }
- else
- {
- cout << "Podteceni" << endl;
- return -1;
- }
- }
- int Pop()
- {
- if(!IsEmpty)
- {
- int ret=Top();
- index--;
- return ret;
- }
- else
- {
- cout << "Podteceni" << endl;
- return -1;
- }
- }
- int main(){
- //Push(5);
- /*for(int i=0; i<=N; i++)
- {
- Push(i);
- }*/
- cout << Top() << endl;
- cout << Pop() << endl;
- cout << IsEmpty();
- getchar();
- getchar();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement