Strukture podataka - Zadatak2


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



Copy this code and paste it in your HTML
  1. GLAVNI PROGRAM
  2. --------------
  3.  
  4. #include<iostream>
  5. #include<cstring>
  6.  
  7. #include "stog_polje.h"
  8.  
  9.  
  10. using namespace std;
  11.  
  12. int upis=0;
  13.  
  14. void dodaj(auti *a){
  15. char jos;
  16. int sb,gd;
  17. char pr[20],md[20];
  18. do{
  19. upis++;
  20. cout << "Serijski broj automobila: ";
  21. cin >> sb;
  22. cout << "Proizvodac automobila: ";
  23. cin.ignore();
  24. cin.getline(pr,20);
  25. cout << "Model automobila: ";
  26. cin.getline(md,20);
  27. opet:cout << "Godiste automobila: ";
  28. cin >> gd;
  29. if(gd<1995 || gd>2010){
  30. cout << "Godiste automobila nije u danom rasponu!" << endl;
  31. goto opet;
  32. }
  33. PushS(sb,pr,md,gd,upis);
  34. cout << "Zelite jos? ";
  35. cin >> jos;
  36. }while(jos=='d');
  37. }
  38.  
  39. void ispis_bez_audi(auti *a,int br_zap){
  40. cout << "Auti proizvedeni poslije 2006.g i nisu marke Audi" << endl;
  41. cout << "-------------------------------------------------" << endl;
  42. for(int i=99-br_zap;i<=99;i++){
  43. TopS_bez(br_zap);
  44. br_zap++;}
  45.  
  46. cout << "Stanje na stogu: " << endl;
  47. cout << "---------------" << endl;
  48. TopS(br_zap-1);
  49. }
  50.  
  51. int audi(int broj,int br_zap){
  52. if(broj==100){
  53. cout << "Stanje na stogu: " << endl;
  54. cout << "----------------" << endl;
  55. TopS(br_zap);
  56. return 1;}
  57. else{
  58. TopS_audi(br_zap);
  59. return audi(broj+1,br_zap+1);}
  60. }
  61.  
  62. int main(){
  63. int izbor;
  64. auti *a=new auti;
  65. int br_zap=0;
  66. do{
  67. cout << endl;
  68. cout << "1.Unos novog automobila" << endl;
  69. cout << "2.Ispis automobila godista veceg od 2006 i bez marke Audi" << endl;
  70. cout << "3.Ispis svih automobila marke Audi" << endl;
  71. cout << "4.Izlaz iz programa" << endl;
  72. cout << "-----------------" << endl;
  73. cout << "Vas izbor? ";
  74. cin >> izbor;
  75. if(izbor==1)br_zap++;
  76. switch(izbor){
  77. case 1:dodaj(a);break;
  78. case 2:ispis_bez_audi(a,br_zap);break;
  79. case 3:{
  80. cout << "Ispis automobila marke Audi" << endl;
  81. cout << "----------------------------" << endl;
  82. int broj=100-br_zap;
  83. audi(broj,br_zap);
  84. }break;
  85. case 4:break;
  86. }
  87. }while(izbor!=4);
  88. system("pause");
  89. return 0;
  90. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.