Posted By


maja90 on 11/22/10

Tagged


Statistics


Viewed 346 times
Favorited by 0 user(s)

Glavni dio - Red u banci


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



Copy this code and paste it in your HTML
  1. #include<iostream>
  2. #include<cstring>
  3. #include "red_polje.h"
  4. using namespace std;
  5.  
  6. int brojac=0;
  7.  
  8. void ispis(red *A){
  9. tbanka ba;
  10. int broj = brojac;
  11. while(broj){
  12. ba=FrontQ(A);
  13. DeQueueQ(A);
  14. cout << endl << "Ime i prezime: " << ba.imeprez << endl;
  15. cout << "Godina rodenja: " << ba.god << endl;
  16. cout << "Stanje na bankovnom racunu (kn): " << ba.stanje << endl;
  17. cout << "Transakcija: " << ba.trans << endl;
  18. EnQueueQ(ba,A);
  19. broj--;
  20. }}
  21.  
  22. void premjesti(red *A){
  23. red *pom = InitQ(pom);
  24. tbanka ba;
  25. int broj = brojac;
  26. while(broj){
  27. ba = FrontQ(A);
  28. DeQueueQ(A);
  29. if(ba.god >1945)
  30. EnQueueQ(ba,pom);
  31. else
  32. EnQueueQ(ba,A);
  33. broj--;
  34. }
  35. while(!IsEmptyQ(pom)){
  36. ba = FrontQ(pom);
  37. DeQueueQ(pom);
  38. EnQueueQ(ba,A);
  39. }
  40. ispis(A);
  41. }
  42.  
  43. void dodaj(red *A){
  44. char jos = 'd';
  45. tbanka ba;
  46. cout << "Dodavanje klijenata: " << endl;
  47. while (jos == 'd' || jos == 'D'){
  48. cout << "Ime i prezime: ";
  49. cin.getline(ba.imeprez, 50);
  50. if (cin.gcount()==1)
  51. cin.getline (ba.imeprez, 50);
  52. cout << "Godina rodjenja: ";
  53. cin >> ba.god;
  54. cout << "Stanje na bankovnom racunu (kn): ";
  55. cin >> ba.stanje;
  56. cout<< "Transakcija (uplata/isplata, placanje, kredit): ";
  57. cin.getline(ba.trans, 50);
  58. if (cin.gcount()==1)
  59. cin.getline (ba.trans, 50);
  60. EnQueueQ(ba,A);
  61. brojac++;
  62. cout << "Zelite dodati jos klijenata (d/n)? ";
  63. cin >> jos;
  64. }
  65. premjesti (A);
  66. }
  67.  
  68.  
  69.  
  70. void izbacivanje(red *A){
  71. if(IsEmptyQ(A)==0){
  72. red *pom = InitQ(pom);
  73. tbanka ba;
  74. int broj = brojac;
  75. while(broj){
  76. ba = FrontQ(A);
  77. DeQueueQ(A);
  78. if(ba.stanje < 100 && strcmp(ba.trans, "kredit") == 0)
  79. brojac--;
  80. else
  81. EnQueueQ(ba,A);
  82. broj--;
  83. }
  84. ispis(A);
  85. }
  86. else
  87. cout << "Red je prazan" << endl;
  88. }
  89.  
  90. void novired(red *A){
  91. if(IsEmptyQ(A)==0){
  92. tbanka ba;
  93. ba = FrontQ(A);
  94. DeQueueQ(A);
  95. if(!IsEmptyQ(A))
  96. novired(A);
  97. EnQueueQ(ba,A);
  98. }
  99. else
  100. cout << "Red je prazan" << endl;
  101. }
  102.  
  103. int main(){
  104. int i;
  105. red *A = InitQ(A);
  106. do{
  107. cout << endl << "Izbornik" << endl;
  108. cout << "1. Dodati klijenta u red " << endl;
  109. cout << "2. Izbacivanje klijenata iz reda " << endl;
  110. cout << "3. Zatvaranje saltera " << endl;
  111. cout << "9. Izlaz " <<endl;
  112. cin >> i;
  113. cout << endl;
  114. switch(i){
  115. case 1:
  116. dodaj(A);
  117. break;
  118. case 2:
  119. izbacivanje(A);
  120. break;
  121. case 3:
  122. novired(A);
  123. ispis (A);
  124. break;
  125. case 9: break;
  126. default: cout << "Pogresan unos" << endl;
  127. }
  128. }while(i!=9);
  129. return 0;
  130. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.