Posted By

DanijelTot on 11/15/10


Tagged

podataka stogpoljestrukture


Versions (?)

stog_polje.h


 / Published in: C++
 

  1. struct tstack {
  2. slot elemnti[100];
  3. int vrh;
  4. };
  5.  
  6. void InitS(tstack *stog) {
  7. stog->vrh=99;
  8. }
  9.  
  10. void PushS(slot x,tstack *stog) {
  11. if (stog->vrh >= 0) {
  12. stog->elemnti[stog->vrh]=x;
  13. stog->vrh--;
  14. }
  15. else exit(0);
  16. }
  17.  
  18. int IsEmptyS(tstack *stog) {
  19. if (stog->vrh==99)
  20. return(0);
  21. else
  22. return(1);
  23. }
  24.  
  25. slot TopS(tstack *stog) {
  26. if (stog->vrh<99)
  27. return(stog->elemnti[stog->vrh+1]);
  28. else exit(0);
  29. }
  30.  
  31. void PopS(tstack *stog) {
  32. if (stog->vrh<99) stog->vrh++;
  33. else exit(0);
  34. }

Report this snippet  

You need to login to post a comment.