Posted By

maradic on 11/15/10


Tagged

main


Versions (?)

main()


 / Published in: C++
 

  1. #include <iostream>
  2. using namespace std;
  3. #include "stog_pokazivaci.h"
  4. //#include "stog_polje.h"
  5. int kraj;
  6. bool print;
  7. void unosi(stog *Stog_marinac) {
  8. elementtype dodaj;
  9. int a;
  10. cout<<"Koliko automobil zelite unesti?" <<endl;
  11. cin >> a;
  12.  
  13.  
  14. for (int i=0;i<a;i++){
  15. cout<<"Unesite serijski broj automobila: "<<endl;
  16. cin>>dodaj.ser_br;
  17. cout<<"Unesite proizvodaca automobila: "<<endl;
  18. cin>>dodaj.proizvodac;
  19. cout<<"Unesite model automobila: "<<endl;
  20. cin>>dodaj.model;
  21.  
  22.  
  23. do{
  24. cout<<"Unesite godinu proizvodnje automobila: "<<endl;
  25. cin>>dodaj.god_pro;
  26. if (dodaj.god_pro < 1995 || dodaj.god_pro > 2010){
  27. cout << "Pogresan unos!" << endl;
  28. cout << "Godina (1995-2010)!" << endl;
  29. cout << "Ponovite unos!" << endl;}
  30. }while (dodaj.god_pro < 1995 || dodaj.god_pro > 2010);
  31. cout << "Uspjesno unesen zapis" << endl;
  32. PushS(dodaj, Stog_marinac);
  33. }
  34. }
  35.  
  36.  
  37.  
  38. void ispis1 (stog *Stog_marinac,stog *Stog_marinac_m){
  39. cout<<"--------"<<endl;
  40. while ( IsEmptyS(Stog_marinac)==0 ){
  41. if (TopS(Stog_marinac).god_pro>2006 && strcmp(TopS(Stog_marinac).proizvodac,"audi")){
  42.  
  43. cout<<"Proizvodac "<< TopS(Stog_marinac).proizvodac<<endl;
  44. cout<<"Model "<< TopS(Stog_marinac).model<<endl;
  45. cout<<"Godina proizvodnje "<< TopS(Stog_marinac).god_pro<<endl;
  46. PopS(Stog_marinac); }
  47. else {
  48. PushS( TopS(Stog_marinac), Stog_marinac_m);
  49. PopS(Stog_marinac);
  50. }
  51. };
  52. cout << "---------"<<endl;
  53. cout << endl;
  54. cout << "Uspjesno" << endl;
  55. cout << endl;
  56. cout << "Preostali automobili"<< endl;
  57. cout << "--------------------"<<endl;
  58. while ( IsEmptyS(Stog_marinac_m)==0 ){
  59. PushS( TopS(Stog_marinac_m), Stog_marinac);
  60. cout<<"Proizvodac: "<<TopS(Stog_marinac).proizvodac<<endl;
  61. cout<<"Model: "<<TopS(Stog_marinac).model<<endl;
  62. cout<<"Godina proizvodnje "<<TopS(Stog_marinac).god_pro<<endl;
  63. PopS(Stog_marinac_m);
  64. }
  65. cout <<"----------------------------" << endl;
  66. }
  67.  
  68.  
  69. int ispis2(stog *Stog_marinac){
  70. elementtype dodaj;
  71. dodaj=TopS(Stog_marinac);
  72. if (!strcmp(dodaj.proizvodac,"audi")) {
  73. cout << "------------"<<endl;
  74. cout << "Iskrcaj automobila Audi " << endl;
  75. cout << "Model: " <<dodaj.model << endl;
  76. cout << "Godina proizvodnje: " <<dodaj.god_pro<<endl;
  77. cout<< "-------------" <<endl;}
  78. PopS(Stog_marinac);
  79. if (!IsEmptyS(Stog_marinac) || kraj) ispis2 (Stog_marinac);
  80.  
  81. kraj = true;
  82. if (strcmp(dodaj.proizvodac,"audi")){
  83. PushS(dodaj, Stog_marinac);
  84. if (print==false){
  85. cout << endl;
  86. cout << "-Preostali automobili-"<< endl;
  87. cout << "------------------"<<endl;
  88. print=true;
  89. };
  90. cout << "Proizvodac " << dodaj.proizvodac<<endl;
  91. cout << "Model automobila " <<dodaj.model<<endl;
  92. cout<< "Godina proizvodnje " <<dodaj.god_pro << endl;
  93.  
  94. }
  95. }
  96. int main(){
  97. int izbor;
  98. stog *Stog_marinac, *Stog_marinac_m;
  99. Stog_marinac=InitS();
  100. Stog_marinac_m=InitS();
  101. do{
  102. cout << "---------IZBORNIK------" << endl;
  103. cout << "1. Dodaj zapis automobila" << endl;
  104. cout << "2. Ispis automobila koji nisu audi" << endl;
  105. cout << "3. Ispis automobila marke audi" << endl;
  106. cout << "9. izlaz "<<endl;
  107. cout << "-----------------------" << endl;
  108. cout << "Unesite izbor koji zelite: " << endl;
  109. cin>>izbor;
  110. cout << endl;
  111. switch(izbor){
  112. case 1: unosi(Stog_marinac);
  113. break;
  114. case 2: ispis1 (Stog_marinac,Stog_marinac_m);
  115. break;
  116. case 3: ispis2 (Stog_marinac);
  117. break;
  118. }
  119. }while (izbor !=9);
  120. system("pause");
  121. return 1;
  122. }

Report this snippet  

You need to login to post a comment.