Return to Snippet

Revision: 35944
at November 15, 2010 08:41 by tojakopec


Initial Code
#include <iostream>

using namespace std;
struct elementtype
{
       int sbroj;
       char proiz[20];
       char model[20];
       int godina;
};


struct list {
       elementtype element;  
       list *next;
};

struct stack
{
       list st;
       list *top;       
};

void Init(stack *S)
{
     S->top = NULL;
     S->st.next = NULL;
}


               
void Push(elementtype x, stack *S)
{
     list *newElement = new list;
     
     newElement->next = S->top;
     newElement->element = x;
     S->top = newElement;
}


elementtype Top(stack *S)
{
     return S->top->element;          
}

bool IsEmpty(stack *S)
{
     if(S->top == NULL)
     {
              return true;         
     }     
     else
     {
              return false;    
     }
}

void Pop(stack *S)
{
     if(IsEmpty(S))
     {
              cout << "Stog je prazan." << endl;     
     }
     else
     {
              delete S->top;
              S->top = S->top->next;            
     }
}

Initial URL


Initial Description


Initial Title
Zadatak 2 - stog_pokazivac.h

Initial Tags


Initial Language
C++