Zadatak 2-MBrlek-pokazivaci


/ 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 value;
  14. struct st *next;
  15. };
  16.  
  17. typedef struct st stack;
  18. typedef stack *element;
  19.  
  20. elementtype TopS(stack *S){
  21. element sljedeci = S->next;
  22. if (sljedeci==NULL) cout << "Stog je prazan..";
  23. else return sljedeci->value;
  24. }
  25.  
  26. void PushS(elementtype x, stack *S){
  27. element novi = new stack;
  28. novi->value = x;
  29. novi->next = S->next;
  30. S->next = novi;
  31. }
  32.  
  33. void PopS(stack *S){
  34. element e = S->next;
  35. S->next = e->next;
  36. delete e;
  37. }
  38.  
  39. void InitS(stack *S){
  40. S->next = NULL;
  41. }
  42.  
  43. bool IsEmptyS(stack *S){
  44. if (S->next==NULL) return true;
  45. else return false;
  46. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.