Return to Snippet

Revision: 35943
at November 15, 2010 08:40 by tojakopec


Initial Code
#include<iostream>

#define n 50

using namespace std;

//int kursor=n-1;
struct elementtype
{
       int sbroj;
       char proiz[20];
       char model[20];
       int godina;
       
};

struct stack {
       elementtype st[n];
       int cursor;
};

void Init(stack *S)
{
     S->cursor = n - 1;     
}


bool IsEmpty(stack *S)
{
     if(S->cursor >= n - 1) 
     {
            return true;
     }
     else 
     {
            return false;
     }
}


void Push(elementtype x, stack *S){
    if(S->cursor == 0)
         cout << "Stog je pun" << endl;        
    else
    {
         S->cursor--;
         S->st[S->cursor] = x;
    }
};

elementtype Top(stack *S)
{
            if(IsEmpty(S))
                         cout << "Nema zapisa\n";
            else
                         return S->st[S->cursor];            
}
void Pop(stack *S){
     if(IsEmpty(S))
                  cout << "\nNema zapisa!\n";
     else
     {
                  S->cursor++;
                  //cout<<"\n\nUnos izbrisan!\n";
     }//else
}//Pop

Initial URL


Initial Description


Initial Title
Zadatak 2. - stog_polje.h

Initial Tags


Initial Language
C++