stog_pokazivac.h


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



Copy this code and paste it in your HTML
  1. struct tstack {
  2. slot vrijednost;
  3. tstack *slje;
  4. };
  5.  
  6. void InitS(tstack *stog) {
  7. stog->slje=NULL;
  8. }
  9.  
  10. void PushS(slot ulaz,tstack *stog) {
  11. tstack *pom;
  12. pom=new tstack;
  13. pom->vrijednost=ulaz;
  14. pom->slje=stog->slje;
  15. stog->slje=pom;
  16. }
  17.  
  18. int IsEmptyS(tstack *stog) {
  19. if (stog->slje==NULL) return(0);
  20. else return(1);
  21. }
  22.  
  23. slot TopS(tstack *stog) {
  24. if (stog->slje != NULL)
  25. return((*stog->slje).vrijednost);
  26. else exit(0);
  27.  
  28. }
  29.  
  30. void PopS(tstack *stog) {
  31. tstack *pom;
  32. pom=stog->slje;
  33. stog->slje=pom->slje;
  34. delete(pom);
  35. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.