/ Published in: C++
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#define n 50 struct stack{ int vrh; int elementi[n]; }; typedef struct stack stog; void InitS(stog *s){ s->vrh=n-1; } int IsEmptyS(stog *s){ if (s->vrh==n-1) return true; else return false; } int TopS(stog *s){ if (IsEmptyS(s)) printf("Stog je prazan!"); else return (s->elementi[s->vrh+1]); } int PopS(stog *s){ if(IsEmptyS(s)) printf("Stog je prazan!"); else s->vrh++; } int PushS(int x,stog *s){ if(s->vrh==0) printf("Stog je pun!"); else s->elementi[s->vrh]=x; s->vrh--; }