osnovni program


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



Copy this code and paste it in your HTML
  1. #include <cstdlib>
  2. #include <iostream>
  3. #include <string.h>
  4.  
  5. #include "stog_pokazivac.h"
  6. //#include "stog_polje.h"
  7.  
  8. using namespace std;
  9.  
  10. stogstog stog;
  11. void ukrcaj()
  12. {
  13. automobil b;
  14. cout << endl << "Marka: ";
  15. cin >> b.marka;
  16. cout << "Model: ";
  17. cin >> b.model;
  18. cout << "Serijski broj: ";
  19. cin >> b.serijskibroj;
  20. do { cout << "Godina proizvodnje: ";
  21. cin >> b.godina;
  22. }while(b.godina<1995 || b.godina>2010);
  23. PushS(b, stog);
  24. cout << endl;
  25. }
  26.  
  27. void autokuca1(char iskljuci[], int god)
  28. {
  29. stogstog pomocni_stog;
  30. pomocni_stog = (stogstog)malloc(sizeof(struct tstog));
  31. InitS(pomocni_stog);
  32. automobil b;
  33.  
  34. while (!IsEmptyS(stog))
  35. {
  36. b = TopS(stog);
  37. PopS(stog);
  38.  
  39. if ((strcmp(b.marka, iskljuci) != 0) && (b.godina > god))
  40. {
  41. cout << b.serijskibroj<< "\t\t\t" << b.marka << "\t\t"<< b.model<< "\t\t"<< b.godina << endl;
  42.  
  43. }
  44. else
  45. {
  46. PushS(b, pomocni_stog);
  47. }
  48.  
  49. while (!IsEmptyS(pomocni_stog))
  50. {
  51. b = TopS(pomocni_stog);
  52. PushS(b, stog);
  53. PopS(pomocni_stog);
  54. }
  55. }
  56. }
  57.  
  58. void autokuca2(char marka[])
  59.  
  60. {
  61. if (!IsEmptyS(stog))
  62. {
  63. automobil b = TopS(stog);
  64. PopS(stog);
  65. int usporedba = strcmp(b.marka, marka);
  66. if (usporedba == 0)
  67. {
  68. cout << b.serijskibroj<< "\t\t\t" << b.marka << "\t\t"<< b.model<< "\t\t"<< b.godina << endl;
  69. }
  70. autokuca2(marka);
  71. if (usporedba != 0) PushS(b, stog);
  72. }
  73. }
  74.  
  75. void pomocni()
  76. {
  77. stogstog pomocni_stog;
  78. pomocni_stog = (stogstog)malloc(sizeof(struct tstog));
  79. InitS(pomocni_stog);
  80. automobil b;
  81. while (!IsEmptyS(stog))
  82. {
  83. b = TopS(stog);
  84. PushS(b, pomocni_stog);
  85. PopS(stog);
  86. }
  87. while (!IsEmptyS(pomocni_stog))
  88. {
  89. b = TopS(pomocni_stog);
  90. cout << b.serijskibroj<< "\t\t\t" << b.marka << "\t\t"<< b.model<< "\t\t"<< b.godina << endl;
  91. PushS(b, stog);
  92. PopS(pomocni_stog);
  93. }
  94. }
  95.  
  96. int main(int argc, char *argv[])
  97. {
  98. int izbor = 9;
  99. int br;
  100.  
  101. stog = (stogstog)malloc(sizeof(struct tstog));
  102. InitS(stog);
  103.  
  104. do
  105. { system("cls");
  106. cout << endl;
  107. cout << "------ I Z B O R N I K----------"<< endl;
  108. cout << "1. Upis automobila" << endl;
  109. cout << "2. Iskrcaj automobila" << endl;
  110. cout << "9. Izlaz" << endl ;
  111. cout<<"________________________________"<<endl << endl;
  112. cout << "Vas izbor je: ";
  113. cin >> izbor;
  114.  
  115. switch (izbor)
  116. {
  117. case 1:
  118. ukrcaj();
  119. break;
  120.  
  121. case 2:
  122. do {
  123. system("cls");
  124. int izbor;
  125. cout << endl;
  126. cout << " ----ISKRCAJ AUTOMOBILA----- " << endl;
  127. cout << " 1. Automobili proizvedeni nakon 2006.godine i nisu marke Audi " << endl;
  128. cout << " 2. Automobili koji su marke Audi " << endl;
  129. cout <<"_________________________________________"<<endl;
  130. cout << "Vas izbor: " ;
  131. cin >>izbor;
  132. switch (izbor) {
  133. case 1:
  134. cout<<endl;
  135. cout <<"Serijski broj"<< "\t\t" <<"Marka" << "\t\t"<< " Model " << "\t\t" << "Godina" << endl;
  136. cout <<"----------------------------------------------------------------"<<endl;
  137. autokuca1((char *)"audi", 2006);
  138. cout<<endl;
  139. cout << "Stanje u pomocnom stogu:" << endl;
  140. cout <<"Serijski broj"<< "\t\t" <<"Marka" << "\t\t"<< " Model " << "\t\t" << "Godina" << endl;
  141. cout <<"----------------------------------------------------------------"<<endl;
  142.  
  143. pomocni();
  144. system("pause");
  145. break;
  146. case 2:
  147. cout<<endl;
  148. cout <<"Serijski broj"<< "\t\t" <<"Marka" << "\t\t"<< " Model " << "\t\t" << "Godina" << endl;
  149. cout <<"----------------------------------------------------------------";
  150. cout << endl;
  151. cout << "Stanje u pomocnom stogu:" << endl;
  152. cout <<"Serijski broj"<< "\t\t" <<"Marka" << "\t\t"<< " Model " << "\t\t" << "Godina" << endl;
  153. cout <<"----------------------------------------------------------------"<<endl;
  154. autokuca2((char *)"audi");
  155. system("pause");
  156. break;
  157.  
  158. }//switch
  159. }while (izbor != 3);
  160.  
  161. }
  162. } while (izbor != 9);
  163.  
  164.  
  165. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.