Header stog_polje.h


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



Copy this code and paste it in your HTML
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct tautomobil {
  5. int sb;
  6. char proizvodac[25];
  7. char model[20];
  8. int godina;
  9. } automobil;
  10.  
  11. struct stog {
  12. int sb[40];
  13. char proizvodac[40][25];
  14. char model[40][20];
  15. int godina[40];
  16. int kursor;
  17. };
  18.  
  19. tautomobil TopS (stog* S){
  20. if(S->kursor != 20) {
  21. automobil.sb = S->sb[S->kursor+1];
  22. strcpy(automobil.proizvodac, S->proizvodac[S->kursor+1]);
  23. strcpy(automobil.model, S->model[S->kursor+1]);
  24. automobil.godina = S->godina[S->kursor+1];
  25. return automobil;
  26. }
  27. }
  28.  
  29. void PushS (tautomobil a, stog* S){
  30. if(S->kursor>=0) {
  31. S->sb[S->kursor] = a.sb;
  32. strcpy(S->proizvodac[S->kursor], a.proizvodac);
  33. strcpy(S->model[S->kursor], a.model);
  34. S->godina[S->kursor] = a.godina;
  35. S->kursor--;
  36. }
  37. }
  38.  
  39. void PopS (stog* S) {
  40. if (S->kursor <= 20)
  41. S->kursor++;
  42. }
  43.  
  44. stog* InitS (stog* S) {
  45. S = new stog;
  46. S -> kursor = 20;
  47. return S;
  48. }
  49.  
  50. bool IsEmptyS (stog* S) {
  51. if (S->kursor == 20) return 1;
  52. else return 0;
  53. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.