Zadatak 2-MBrlek-polje


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



Copy this code and paste it in your HTML
  1. using namespace std;
  2.  
  3. struct automobil{
  4. int br;
  5. int god;
  6. char proizvodac[30];
  7. char model[30];
  8. };
  9.  
  10. typedef automobil elementtype;
  11.  
  12. struct st {
  13. elementtype elementtypes[1000];
  14. int top;
  15. };
  16.  
  17. typedef struct st stack;
  18.  
  19. elementtype TopS(stack *S){
  20. if ((*S).top==999) cout << "Stog je prazan..";
  21. else return ((*S).elementtypes[(*S).top+1]);
  22. }
  23.  
  24. void PushS(elementtype x, stack *S){
  25. if ((*S).top<0) cout << "Stog je popunjen";
  26. else{
  27. (*S).elementtypes[(*S).top] = x;
  28. (*S).top--;
  29. }
  30. }
  31.  
  32. void PopS(stack *S){
  33. if ((*S).top==999) cout << "Stog je prazan..";
  34. else (*S).top++;
  35. }
  36.  
  37. bool IsEmptyS(stack *S){
  38. if ((*S).top==999) return true;
  39. else return false;
  40. }
  41.  
  42. void InitS(stack *S){
  43. (*S).top = 999;
  44. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.