Posted By


vebalazin on 11/15/10

Tagged


Statistics


Viewed 67 times
Favorited by 0 user(s)

Stog_polje.h_Vebalazin


/ Published in: C++
Save to your folder(s)



Copy this code and paste it in your HTML
  1. #define n 50
  2.  
  3. struct stack{
  4. int vrh;
  5. int elementi[n];
  6. };
  7. typedef struct stack stog;
  8.  
  9. void InitS(stog *s){
  10. s->vrh=n-1;
  11. }
  12.  
  13. int IsEmptyS(stog *s){
  14. if (s->vrh==n-1)
  15. return true;
  16. else
  17. return false;
  18. }
  19.  
  20. int TopS(stog *s){
  21. if (IsEmptyS(s))
  22. printf("Stog je prazan!");
  23. else
  24. return (s->elementi[s->vrh+1]);
  25. }
  26.  
  27. int PopS(stog *s){
  28. if(IsEmptyS(s))
  29. printf("Stog je prazan!");
  30. else
  31. s->vrh++;
  32. }
  33.  
  34. int PushS(int x,stog *s){
  35. if(s->vrh==0)
  36. printf("Stog je pun!");
  37. else
  38. s->elementi[s->vrh]=x;
  39. s->vrh--;
  40. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.