fork download
#include <iostream>
using namespace std;
class Stack {
private:
    int size;
    int Top;
    int *Arr;

public:
    Stack(int s) {
        Arr = new int[s];
        Top = -1;
        size = s;
    }

    bool IsEmpty() {
        return (Top == -1);
    }

    bool IsFull() {
        return (Top + 1 == size);
    }

    void Push(int value) {
        if (IsFull()) {
            cout << "Can't Add .. Stack is full." << endl;
        } else {
            Top++;
            Arr[Top] = value;
        }
    }

    int Pop() {
        if (IsEmpty()) {
            cout << "Can't Delete... Stack is empty." << endl;
        } else {
            return (Arr[Top--]);
        }
    }

    int Peek() {
        if (IsEmpty()) {
            cout << "No Values ..." << endl;
        } else {
            return (Arr[Top]);
        }
    }

    void Display() {
        for (int i = Top; i >= 0; i--) {
            cout << Arr[i] << " ";
        }
        cout << endl;
    }
};


int main() {
	// your code goes here
	return 0;
}
Success #stdin #stdout 0.01s 5304KB
stdin
Standard input is empty
stdout
Standard output is empty