Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class stos
- {
- public:
- void push(int element);
- int pop();
- private:
- int s[10];
- int n=0;
- };
- void stos::push(int element)
- {
- if (n<10)
- s[n++]=element;
- else
- cout <<"Stos jest pelny";
- };
- int stos::pop()
- {
- if (n>0)
- return s[--n];
- cout <<"Stos jest pusty";
- return 0;
- }
- int main()
- {
- stos *stoz;
- stoz=new stos;
- int co=0,ile=0;
- char what='c';
- while (what!='x')
- {
- cout <<"Co chcesz zrobic?"<<endl;
- cin >>what;
- switch (what)
- {
- case'a':
- ile++;
- cin>>co;
- stoz->push(co);
- break;
- case'b':
- stoz->pop();
- break;
- default:
- break;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement