Z3_red_u_banci (glavni program)


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



Copy this code and paste it in your HTML
  1. #include<iostream>
  2. #include "red_polja.h"
  3. //#include "red_pokazivaci.h"
  4. using namespace std;
  5. int brojac=0;
  6.  
  7. void ispis(tred *red){
  8. tklijent pom;
  9. cout<<"\nPopis klijenata u redu:"<<endl;
  10. for(int i=0; i<brojac; i++){
  11. pom = FrontQ(red);
  12. DeQueueQ(red);
  13. cout<<"---------------------------"<<endl;
  14. cout<<"Ime i prezime: "<<pom.prez_ime<<endl;
  15. cout<<"Godiste: "<<pom.godiste<<endl;
  16. cout<<"Stanja racuna: "<<pom.stanje<<endl;
  17. cout<<"Transakcija: "<<pom.transakcija<<endl;
  18. EnQueueQ(pom, red);
  19. }
  20. cout<<"---------------------------"<<endl<<endl;
  21. }
  22.  
  23. void stariji_prednost(tred *red, tred *pom_red){
  24. tklijent pom;
  25. for(int i=0; i<brojac; i++){
  26. pom = FrontQ(red);
  27. DeQueueQ(red);
  28. if(pom.godiste<1945)
  29. EnQueueQ(pom, red);
  30. else{
  31. EnQueueQ(pom, pom_red);
  32. }
  33. }
  34. while(!IsEmptyQ(pom_red)){
  35. pom = FrontQ(pom_red);
  36. DeQueueQ(pom_red);
  37. EnQueueQ(pom, red);
  38. }
  39. ispis(red);
  40. }
  41.  
  42. void unos(tred *red){
  43. char jos;
  44. tklijent x, pom;
  45. do{
  46. cout<<"Ime i prezime: ";
  47. cin.ignore();
  48. cin.getline(x.prez_ime, 20);
  49. cout<<"Godiste: ";
  50. cin>>x.godiste;
  51. cout<<"Stanja racuna: ";
  52. cin>>x.stanje;
  53. cout<<"Transakcija: ";
  54. cin>>x.transakcija;
  55. EnQueueQ(x, red);
  56. brojac++;
  57. cout<<"Zelite li unijeti jos? (d/n) ";
  58. cin>>jos;
  59. }while(jos=='d');
  60. ispis(red);
  61. }
  62.  
  63. void izbacivanje(tred *red){
  64. tklijent pom;
  65. int broj = brojac;
  66. while(broj!=0){
  67. pom = FrontQ(red);
  68. DeQueueQ(red);
  69. if(pom.stanje<100&&(strcmp(pom.transakcija, "kredit")==0))
  70. brojac--;
  71. else
  72. EnQueueQ(pom, red);
  73. broj--;
  74. }
  75. ispis(red);
  76. }
  77.  
  78. void novi_salter(tred *red){
  79. tklijent pom = FrontQ(red);
  80. DeQueueQ(red);
  81. if (!IsEmptyQ(red))
  82. novi_salter(red);
  83. EnQueueQ(pom, red);
  84. }
  85.  
  86. using namespace std;
  87. int main(){
  88. tred *red=new tred;
  89. InitQ(red);
  90. tred *pom_red=new tred;
  91. InitQ(pom_red);
  92. int izbor;
  93. do{
  94. cout<<"==============================IZBOR============================="<<endl;
  95. cout<<"1. Unos klijenata u red"<<endl;
  96. cout<<"2. Pustanje klijenata starijih od 65 godina na pocetak red"<<endl;
  97. cout<<"3.|Izbacivanje klijenata iz reda koji traze kredit, \n |a imaju manje od 100 kn na racunu"<<endl;
  98. cout<<"4. Zatvaranje trenutnog saltera i otvaranje novog"<<endl;
  99. cout<<"================================================================"<<endl;
  100. cout<<"Izbor: ";
  101. cin>>izbor;
  102. cout<<endl;
  103. switch(izbor){
  104. case 1: unos(red);
  105. break;
  106. case 2: stariji_prednost(red, pom_red);
  107. break;
  108. case 3: izbacivanje(red);
  109. break;
  110. case 4: novi_salter(red);
  111. ispis(red);
  112. break;
  113. case 9: break;
  114. default: cout<<"Pogresan unos!"<<endl;
  115. }
  116. }while(izbor!=9);
  117. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.