Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int N;
- int *tab;
- int q=0;
- int p=0;
- bool isEmpty()
- {
- return(p==(-1));
- }
- bool isFull()
- {
- return(p==N);
- }
- void push(int a)
- {
- if(!isFull()){
- for(int i=N-1;i>=0;i--){
- tab[i]=tab[i-1];
- }
- tab[0]=a;
- p=p+1;
- }
- else
- {
- cout<<"Stos pelny\t"<<endl;
- }
- }
- void print()
- {
- if(isEmpty())
- {
- cout << "Pusty stos\n";
- return;
- }
- for (int i = 0; i<p; i++)
- {
- cout << tab[i] <<"\t";
- }
- cout << endl;
- }
- int main()
- {
- tab = new int[N];
- N=5;
- for(int i=0;i<5;i++){
- tab[i]=0;
- }
- push(2);
- push(3);
- push(4);
- push(1);
- print();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement