Guest User

Untitled

a guest
Jun 21st, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.69 KB | None | 0 0
  1. //Glavni program
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. struct car {
  6. double serial_number;
  7. char brand [20];
  8. char model[20];
  9. int year;
  10. };
  11. typedef car elementtype;
  12.  
  13.  
  14. //#include "stog_pokazivac.h"
  15. #include "stog_polje.h"
  16.  
  17. int storage(S_stack *skladiste, elementtype temporary) {
  18. cout<<"\nUnesite serijski broj auta: "; cin>>temporary.serial_number;
  19. cout<<"Unesite proizvodaca auta: "; cin>>temporary.brand;
  20. cout<<"Unesite model auta: "; cin>>temporary.model;
  21. do{
  22. cout<<"Unesite godinu proizvodnje auta: "; cin>>temporary.year;
  23. if (temporary.year < 1995 || temporary.year > 2010)
  24. cout<<"Godina mora biti u rasponu 1995-2010."<<endl;
  25. } while (temporary.year < 1995 || temporary.year > 2010);
  26.  
  27. PushS(temporary, skladiste);
  28. return 0;
  29. }
  30.  
  31.  
  32. int unloading1 (S_stack *skladiste,S_stack *PomStack){
  33. cout<<"Auto kuca 1 (iskrcaj autiju starijih od 2006 koji nisu Audi"<<endl;
  34. while (IsEmptyS(skladiste)==0 ){
  35. if (TopS(skladiste).year>2006 && strcmp(TopS(skladiste).brand,"Audi")){
  36. cout<<"\n############# Iskrcaj auta "<<TopS(skladiste).serial_number<<" ###########"<<endl;
  37. cout<<TopS(skladiste).brand<<" "<<TopS(skladiste).model<<" , proizveden "<<TopS(skladiste).year<<endl;
  38. cout<<"############################################\n"<<endl;
  39. PopS(skladiste);
  40. }
  41.  
  42. else {
  43. PushS( TopS(skladiste), PomStack);
  44. PopS(skladiste);
  45. }
  46. };
  47. cout<<"Stanje na skladistu"<<endl;
  48. while ( IsEmptyS(PomStack)==0 ){
  49. PushS( TopS(PomStack), skladiste);
  50. cout<<TopS(skladiste).serial_number<<"\t"<<TopS(skladiste).brand<<" "<<TopS(skladiste).model<<", proizveden "<<TopS(skladiste).year<<endl;
  51. PopS(PomStack);
  52. }
  53. }
  54.  
  55. int kraj=0;
  56.  
  57. int unloading2(S_stack *skladiste, elementtype temporary){
  58. temporary=TopS(skladiste);
  59. PopS(skladiste);
  60. if (!IsEmptyS(skladiste) || kraj==1) unloading2 (skladiste, temporary);
  61. kraj = 1;
  62. if (!strcmp(temporary.brand,"Audi")){
  63. cout<<"\n############### Iskrcaj auta "<<temporary.serial_number<<" ###########"<<endl;
  64. cout<<temporary.brand<<" "<<temporary.model<<" , proizveden "<<temporary.year<<endl;
  65. cout<<"############################################\n"<<endl;
  66. }
  67. else{
  68. PushS(temporary, skladiste);
  69. cout<<TopS(skladiste).serial_number<<" "<<TopS(skladiste).brand<<" "<<TopS(skladiste).model<<", proizveden "
  70. <<TopS(skladiste).year<<" ostaje na skladistu "<<endl;
  71. } }
  72.  
  73.  
  74.  
  75. int main(){
  76. int i,br, izbor, izbor2;
  77. elementtype temporary;
  78. S_stack *skladiste, *PomStack;
  79. skladiste=InitS();
  80. PomStack=InitS();
  81. cout<<"Koliko autiju prevozite" <<endl;
  82. cin>>br;
  83. cout<<"Unesite podatke o autima koje ukrcavate"<<endl;
  84. for (i=0;i<br;i++) storage(skladiste, temporary);
  85.  
  86. cout<<"\nAuti ukrcani"<<endl;
  87. cout<<"Izaberite rutu: "<<endl;
  88. cout<<"1. auto kuca 1 (iskrcaj autiju proizvedenih nakon 2006 (ne audi)"<<endl;
  89. cout<<"2. auto kuca 2 (iskrcaj Audija"<<endl;
  90. cin>>izbor;
  91. switch (izbor){
  92. case 1: unloading1 (skladiste,PomStack); break;
  93. case 2: unloading2 (skladiste,temporary); break;
  94. };
  95. cout<<"\n\}Kraj rada ili odlazak i u drugu autu kucu??"<<endl;
  96. cout<<"1. Nastavak puta i odlazak u drugu auto kucu"<<endl;
  97. cout<< "2. Kraj"<<endl;
  98. cin>>izbor2;
  99. switch (izbor2){
  100. case 1: if(izbor==1) {
  101. cout<<"Auto kuca 2 (iskrcaj autiju proizvodaca Audi\n"<<endl;
  102. unloading2(skladiste,temporary);
  103. }
  104. else unloading1 (skladiste,PomStack);
  105. break;
  106. }
  107.  
  108. system ("pause");
  109. return 0;
  110. }
Add Comment
Please, Sign In to add comment