stog_pokazivac.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 tskladiste {
  5. int serijskibr;
  6. char proizvodac[20];
  7. char model[20];
  8. int godpro;
  9. }automobil; //struct
  10.  
  11. struct stog {
  12. int serijskibr;
  13. char proizvodac[20];
  14. char model[20];
  15. int godpro;
  16. stog *sljedeci;
  17. }; //struct
  18.  
  19. tskladiste TopS(stog *S) {
  20. if (S->sljedeci) {
  21. automobil.serijskibr = S->sljedeci->serijskibr;
  22. strcpy(automobil.proizvodac, S->sljedeci->proizvodac);
  23. strcpy(automobil.model, S->sljedeci->model);
  24. automobil.godpro = S->sljedeci->godpro;
  25. return automobil;
  26. }
  27. } //TopS
  28.  
  29. void PushS(tskladiste x, stog *S) {
  30. stog* novi=new stog;
  31. novi->serijskibr=x.serijskibr;
  32. strcpy(novi->proizvodac, x.proizvodac);
  33. strcpy(novi->model, x.model);
  34. novi->godpro = x.godpro;
  35. novi->sljedeci=S->sljedeci;
  36. S->sljedeci=novi;
  37. }; //PushS
  38.  
  39. void PopS(stog *S){
  40. if (S->sljedeci) {
  41. stog* tekuci=S->sljedeci;
  42. S->sljedeci=tekuci->sljedeci;
  43. delete tekuci;
  44. }
  45. }; //PopS
  46.  
  47. stog* InitS(stog *S) {
  48. S = new stog;
  49. S->sljedeci = NULL;
  50. return S;
  51. } //InitS
  52.  
  53. bool IsEmptyS(stog *S){
  54. if (S->sljedeci)
  55. return 0;
  56. else
  57. return 1;
  58. } //IsEmptyS

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.