Posted By

lusumar on 11/15/10


Tagged


Versions (?)

polje.h


 / Published in: C++
 

  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. struct stog {
  11. int sb[40];
  12. char proizvodac[40][25];
  13. char model[40][20];
  14. int godina[40];
  15. int kursor;
  16. };
  17. tautomobil TopS (stog* S){
  18. if(S->kursor != 20) {
  19. automobil.sb = S->sb[S->kursor+1];
  20. strcpy(automobil.proizvodac, S->proizvodac[S->kursor+1]);
  21. strcpy(automobil.model, S->model[S->kursor+1]);
  22. automobil.godina = S->godina[S->kursor+1];
  23. return automobil;
  24. }
  25. }
  26. void PushS (tautomobil a, stog* S){
  27. if(S->kursor>=0) {
  28. S->sb[S->kursor] = a.sb;
  29. strcpy(S->proizvodac[S->kursor], a.proizvodac);
  30. strcpy(S->model[S->kursor], a.model);
  31. S->godina[S->kursor] = a.godina;
  32. S->kursor--;
  33. }
  34. }
  35. void PopS (stog* S) {
  36. if (S->kursor <= 20)
  37. S->kursor++;
  38. }
  39. stog* InitS (stog* S) {
  40. S = new stog;
  41. S -> kursor = 20;
  42. return S;
  43. }
  44. bool IsEmptyS (stog* S) {
  45. if (S->kursor == 20) return 1;
  46. else return 0;
  47. }

Report this snippet  

You need to login to post a comment.