Return to Snippet

Revision: 35935
at November 15, 2010 08:14 by aldelic


Initial Code
#include<iostream>
#define n 50
using namespace std;
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++;      
     }
}

Initial URL

                                

Initial Description

                                

Initial Title
Program automobil stog_polje.h

Initial Tags

                                

Initial Language
C++