Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- #define MAX 10
- struct Stack{
- int array[MAX];
- int top;
- void init();
- bool isFull();
- bool isEmpty();
- void push(int e);
- int pop(int br);
- int peek(int p);
- };
- void Stack::init()
- {
- top=-1;
- }
- bool Stack::isEmpty()
- {
- return (top==-1);
- }
- bool Stack::isFull()
- {
- return(top==MAX-1);
- }
- void Stack::push(int br)
- {
- if(isFull())
- {
- cout<<"Magacinot e poln"<<endl;
- }
- else
- {
- array[++top]=br;
- }
- }
- int Stack::pop(int br)
- {
- if(!isEmpty())
- {
- return (array[top--]) ;
- }
- else{
- cout<<"Magacinot e prazen"<<endl;
- }
- }
- int Stack::peek(int p)
- {
- return array[top];
- }
- int najdiPozicija(Stack magacin, int broj)
- {
- int i=0;
- while(!magacin.isEmpty)
- {
- if(magacin.peek==broj)
- {
- i=MAX-magacin.top-1;
- }
- }
- return i;
- }
- int main()
- {
- Stack magacin;
- int broj;
- magacin.init();
- for (int i = 0; i < 10; i++)
- {
- cin >> broj;
- magacin.push(broj);
- }
- cin >> broj;
- int pozicija = najdiPozicija(magacin, broj);
- void izbrishi(Stack magacin, int i);
- cout<<pozicija<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement