Return to Snippet

Revision: 36315
at November 20, 2010 10:57 by majstorica


Initial Code
#include <iostream>
#include "red_pok.h"
//#include red_pol.h

using namespace std;

int br_kl=0;

void ispis_reda(qu *red){
     elementtype pom;
     for (int i=0;i<br_kl;i++){
         pom = FrontQ(red);
         DequeueQ(red);
         EnqueueQ(pom,red) ;
         cout <<"--------------------------------\n";
         cout <<"Ime klijenta     : "<<pom.ime<<endl;
         cout <<"Prezime klijenta : "<<pom.prezime<<endl;
         cout <<"Godina rodenja   : "<<pom.godina<<endl;
         cout <<"Stanje racuna    : "<<pom.stanje<<endl;
         cout <<"Opcija klijenta  : "<<pom.trans<<endl;    
     }          
}

void penzici(elementtype pom, qu *red){
     elementtype pom_1;
     qu *pom_red = new qu;
     InitQ(pom_red);
     int i=0;
     if (pom.godina <= 1945){
        
        while (!IsEmptyQ(red)){ 
              EnqueueQ(FrontQ(red),pom_red);
              DequeueQ(red); 
              i++;                                      
        } 
        EnqueueQ(pom,red);
        
        while (!IsEmptyQ(pom_red)){
              
              EnqueueQ(FrontQ(pom_red), red);
              DequeueQ(pom_red);                                    
        }         
     }
     else EnqueueQ(pom,red);     
}

void ulazak_klijenta(qu *red){
     elementtype pom;
     char jos;
     do{
         cout <<"Ime klijenta     : ";
         cin.ignore();
         cin.getline(pom.ime,20);  
         cout <<"Prezime klijenta : ";
         cin.getline(pom.prezime,20);  
         do{
             cout <<"Godina rodenja   : ";
             cin >> pom.godina;
         }while(pom.godina <1900 || pom.godina>2010);
         cout <<"Stanje racuna    : ";
         cin >> pom.stanje;
         do{
             cout <<"\nVrsta usluge : \n";
             cout <<"1. Uplata/Isplata\n";
             cout <<"2. Placanje racna\n";
             cout <<"3. Kreditiranje\n";
             cout <<"Vas izbor : "; cin >> pom.trans;
         }while(pom.trans != 1 && pom.trans != 2 && pom.trans != 3);
         penzici(pom,red);
         br_kl++;
         cout <<"Unositi jos klijenata (d/n):"; cin >> jos;
         
     }while(jos =='d'|| jos=='D');
}

void izbaci_nekreditne(qu *red){
     elementtype pom;
     int prom=0;
     for(int i=0;i<br_kl;i++){
             pom = FrontQ(red);
             
             DequeueQ(red);
             prom--;
             if (pom.trans == 3 && pom.stanje<100){
                cout <<"--------------------------------\n";
                cout <<"Ime klijenta     : "<<pom.ime<<endl;
                cout <<"Prezime klijenta : "<<pom.prezime<<endl;
                cout <<"Godina rodenja   : "<<pom.godina<<endl;
                cout <<"Stanje racuna    : "<<pom.stanje<<endl;
                cout <<"Opcija klijenta  : "<<pom.trans<<endl;                
             }   
             else{
                 EnqueueQ(pom,red);
                 prom++;
             }    
     }  
     br_kl=br_kl+prom;  
}

void novi_red(qu *red,int b_red){
     elementtype pom;
     if (!IsEmptyQ(red) && b_red!=0){
        pom = FrontQ(red);
        DequeueQ(red);
        if (pom.godina<1945)
           EnqueueQ(pom,red); 
        b_red--;                       
        novi_red(red,b_red);
        if (pom.godina>=1945)
           EnqueueQ(pom,red);                                    
     }
     else return;         
}
int main(){
    int izbor;
    qu *red = new qu;
    InitQ(red);
    do{
       cout <<"\nIZBORNIK\n\n";
       cout <<"1. Dodavanje zapisa o klijentima banke\n";
       cout <<"2. Odobravanje kredita?\n";
       cout <<"3. Otvoraranje/zatvaranje saltera\n";
       cout <<"9. Izlaz iz programa\n";
       cout <<"\nVas izbor : "; cin >>izbor;
       switch (izbor){
              case 1:
                   cout <<"\n---------Ulazak klijenta-------\n\n";
                   ulazak_klijenta(red);
                   ispis_reda(red);
                   break;  
              case 2:
                   if (!IsEmptyQ(red)){
                       cout <<"\nIzbacujem : \n";
                       izbaci_nekreditne(red);
                       cout <<"\nStanje reda : \n";
                       ispis_reda(red);
                   }
                   else cout <<"\nNikog nema u redu !!\n\n";
                   break;
              case 3:
                   int b_red;
                   b_red=br_kl;
                   if (!IsEmptyQ(red)){
                       novi_red(red,b_red);
                       ispis_reda(red);
                   }
                   else cout <<"\nNikog nema u redu !!\n\n";
                   break;
              case 9:
                   break;     
       }       
    }while(izbor != 9);
    
return 0;    
}

//Iva Kis

Initial URL

                                

Initial Description

                                

Initial Title
simulacija reda u banci.cpp

Initial Tags

                                

Initial Language
C++