Posted By


SPcakaSP on 11/14/10

Tagged


Statistics


Viewed 386 times
Favorited by 0 user(s)

Osnovni dio programa


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



Copy this code and paste it in your HTML
  1. #include<iostream>
  2. #include"stog_polje.h"
  3. //#include"stog_pokazivac.h"
  4. using namespace std;
  5. void ispis(stog* S) {
  6. tautomobil pom[40];
  7. int br=0;
  8. while(!IsEmptyS(S)){
  9. automobil = TopS(S);
  10. pom[br] = automobil;
  11. br++;
  12. PopS(S);
  13. }//eo while
  14. for (int i=br-1;i>=0;i--) {
  15. cout<<"Serijski broj: "<<pom[i].sb<<endl;
  16. cout<<"Proizvodac: "<<pom[i].proizvodac<<endl;
  17. cout<<"Model: "<<pom[i].model<<endl;
  18. cout<<"Godina: "<<pom[i].godina<<endl<<endl;
  19. automobil = pom[i];
  20. PushS(automobil, S);
  21. }//eo for
  22. }//eof ispis
  23. void unos (stog* S){
  24. char jos;
  25. bool p=false;
  26. b:
  27. cout<<"Proizvodjac: ";
  28. cin.ignore();
  29. cin.getline(automobil.proizvodac, 30);
  30. a:
  31. cout<<"Model: ";
  32. if (p) cin.ignore();
  33. cin.getline(automobil.model, 30);
  34. cout<<"Serijski broj: ";
  35. cin>>automobil.sb;
  36. do {
  37. cout<<"Godina proizvodnje: ";
  38. cin>>automobil.godina;
  39. if (automobil.godina < 1995 ||automobil.godina>2010) cout<<"Godina nije u rasponu! "<<endl;
  40. } while (automobil.godina < 1995 ||automobil.godina>2010);
  41. PushS(automobil, S);
  42. cout<<"Zelis li novi model, proizvodjaca ili nista od toga (m,p,n) ?";
  43. cin>>jos;
  44. if (jos=='m') {p=true;goto a;}
  45. if (jos=='p') {p=false;goto b;}
  46. }//eof unos
  47. void prvi (stog *S, stog* pomocni) {
  48. if(!IsEmptyS(S)) {
  49. tautomobil pom;
  50. cout<<"----------Automobili koji izlaze--------------"<<endl;
  51. while(!IsEmptyS(S)){
  52. pom = TopS(S);
  53. PopS(S);
  54. PushS(pom, pomocni);
  55. if(pom.godina>=2006)
  56. if (strcmp(pom.proizvodac,"audi")){
  57. cout<<"Serijski broj: "<<pom.sb << endl;
  58. cout<<"Proizvodac: "<<pom.proizvodac << endl;
  59. cout<<"Model: "<<pom.model << endl;
  60. cout<<"Godina: "<<pom.godina << endl<<endl;
  61. }//eo if
  62. }//eo while
  63. while(!IsEmptyS(pomocni)) {
  64. pom = TopS(pomocni);
  65. PopS(pomocni);
  66. if(pom.godina<2006 || !strcmp(pom.proizvodac,"audi"))
  67. PushS(pom,S);
  68. }//eo while
  69. cout<<"---------------Automobili koji su ostali----------------"<<endl;
  70. ispis(S);
  71. }//eo if
  72. }//eof prvi
  73. void drugi(stog* S) {
  74. if(!IsEmptyS(S)) {
  75. tautomobil pom = TopS(S);
  76. if(!strcmp(pom.proizvodac,"audi")){
  77. cout<<"Serijski broj: "<<pom.sb<<endl;
  78. cout<<"Proizvodac: "<<pom.proizvodac<<endl;
  79. cout<<"Model: "<<pom.model<<endl;
  80. cout<<"Godina: "<<pom.godina<<endl<<endl;}//eo if
  81. PopS(S);
  82. if(!IsEmptyS(S))
  83. drugi(S);
  84. if(strcmp(pom.proizvodac,"audi"))
  85. PushS(pom, S);
  86. }//eo if
  87. }//eof drugi
  88. int main () {
  89. int izb;
  90. stog *S = InitS(S);
  91. stog *pom = InitS(pom);
  92. do {
  93. cout<<"-----------IZBORNIK--------------"<<endl;
  94. cout<<"1. Unos automobila"<<endl;
  95. cout<<"2. Iskrcaj na prvoj stanici"<<endl;
  96. cout<<"3. Iskrcaj na drugoj stanici"<<endl;
  97. cout<<"9. Izlaz"<<endl;
  98. cout<<"---------------------------------"<<endl;
  99. cin>>izb;
  100. switch (izb) {
  101. case 1: unos(S);
  102. break;
  103. case 2: prvi(S,pom);
  104. break;
  105. case 3: cout<<"-------------Iskrcavam sljedece automobile--------------"<<endl;
  106. drugi(S);
  107. cout<<"------------Automobili koji su ostali u kamionu-----------"<<endl;
  108. ispis(S);
  109. break;
  110. case 9: cout<<"Pozz"<<endl;
  111. break;
  112. default: cout<<"Krivi izbor, daj ponovno"<<endl;
  113. }
  114. } while (izb!=9);
  115. system ("pause");
  116. return 0;
  117. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.