#include<iostream>  #include<ctime> #include<cstring> #include"red_polje.h" //#include"red_pokazivaci.h" using namespace std;  klijent x[10000], *polje; int n;  void generiranje(int n) {   srand(time(NULL));    bool punoljetan;    for(int i=0; i<n; i++)   {     time_t t = time(0);     struct tm *now = localtime(&t);     do     {       x[i].g = (time_t) (rand()%83 + ((int)now->tm_year+1900-100));       x[i].m = (time_t) (rand()%12+1);       if((int)x[i].m==1 || (int)x[i].m==3 || (int)x[i].m==5 ||          (int)x[i].m==7 || (int)x[i].m == 8 || (int)x[i].m == 10 || (int)x[i].m == 12)          x[i].d = (time_t) (rand()%31+1);       else if(x[i].m == 2)       {         if((int)x[i].g%4==0 && (int)x[i].g%100!=0 && (int)x[i].g%400==0)           x[i].d = (time_t) (rand()%29+1);         else           x[i].d = (time_t) (rand()%28+1);       }       else         x[i].d = (time_t) (rand()%30+1);        punoljetan = true;        if(now->tm_year+1900-x[i].g == 18)       {         if(x[i].m > (now->tm_mon+1))           punoljetan = false;         else if(x[i].m == (now->tm_mon+1))           if(x[i].d > now->tm_mday)             punoljetan = false;       }     } while(!punoljetan);      x[i].cet.ai = rand()%401+100;     x[i].cet.bi = rand()%401+100;     if(now->tm_year+1900-x[i].g > 66)       x[i].cet.ci = 1;     else       x[i].cet.ci = rand()%5+2;     x[i].cet.di = rand()%4+1;     while(x[i].cet.ci==6 && x[i].cet.di==2)        x[i].cet.di = rand()%4+1;      int kune, lipe, predznak, koef;      kune = rand();     lipe = rand()%100+0;          koef = rand()%3+1;     if(koef == 1)       koef = 1;     if(koef == 2)       koef = 10;     if(koef == 3)       koef = 100;      if(kune == 0 && lipe == 0)       predznak == 1;     else       predznak = rand()%2+1;     if(predznak == 1)       x[i].tekuci = (float)(koef*kune+lipe/100);     else       x[i].tekuci = (float)(-(koef*kune+lipe/100));      kune = rand();     lipe = rand()%100+0;     x[i].devizni = (float)(koef*kune+lipe/100);   }   cout << endl; }  void zapisi(int n) {   queue Qp;   InitQ(Qp);    InitQ(Q);    for(int i=n-1; i>0; i--)   {     for(int j=0; j<i; j++)       if(x[j].cet.ci > x[i].cet.ci)       {         klijent pom = x[j];         x[j] = x[i];         x[i] = pom;       }   }    cout.setf(ios::fixed, ios::floatfield);   cout.precision(2);    for(int i=0; i<n; i++)   {      char id[10000];      itoa(i+1, id, 10);      strcpy(x[i].prez_ime, "Klijent ");      strcat(x[i].prez_ime, id);      cout << "Prezime i ime: " << x[i].prez_ime << endl;      cout << "Datum rodjenja: " << x[i].d << "." << x[i].m << "." << x[i].g << "." << endl;      cout << "Stanje na tekucem racunu(kuna): " << x[i].tekuci << endl;      cout << "Stanje na deviznom racunu(euro): " << x[i].devizni << endl;      cout << "Broj prioriteta: " << x[i].cet.ci << endl;      cout << "Broj transakcije: " << x[i].cet.di << endl;      cout << "__________________________________________________" << endl;      EnQueueQ(x[i], Q);   }    cout << "Klijenti koji na racunu imaju vise od 10.000,00 kn"        << " u odabranoj stranoj valuti:" << endl;   while(!IsEmptyQ(Q))   {     EnQueueQ(FrontQ(Q), Qp);     DeQueueQ(Q);   }    float pare = 10000, koef = 7.5;    InitQ(Q);    while(!IsEmptyQ(Qp))   {     if(FrontQ(Qp).devizni*koef >= pare)       cout << "Ime i prezime: " << FrontQ(Qp).prez_ime << endl            << "Stanje na deviznom racunu(euro->kuna): " << endl            << FrontQ(Qp).devizni << "*" << "7.50" << " = "            << FrontQ(Qp).devizni*koef << endl            << "_____________________________________" << endl;     EnQueueQ(FrontQ(Qp), Q);     DeQueueQ(Qp);   }    cout.unsetf(ios::floatfield);    cout << endl; }  void brzi_red() {   queue Qp, Qbrzi;   InitQ(Qp);   InitQ(Qbrzi);    while(!IsEmptyQ(Q))   {     if(FrontQ(Q).cet.di == 3)     {       EnQueueQ(FrontQ(Q), Qbrzi);       n--;     }     else       EnQueueQ(FrontQ(Q), Qp);     DeQueueQ(Q);   }   InitQ(Q);   cout << "Stanje glavnog reda:" << endl;   while(!IsEmptyQ(Qp))   {     cout << "Ime i prezime: " << FrontQ(Qp).prez_ime << endl          << "Broj prioriteta: " << FrontQ(Qp).cet.ci << endl          << "Broj transakcije: " << FrontQ(Qp).cet.di << endl          << "_____________________________________" << endl;     EnQueueQ(FrontQ(Qp), Q);     DeQueueQ(Qp);   }   cout << endl << "*******************" << endl;   cout << "Stanje brzog reda:" << endl;   while(!IsEmptyQ(Qbrzi))   {     cout << "Ime i prezime: " << FrontQ(Qbrzi).prez_ime << endl          << "Broj prioriteta: " << FrontQ(Qbrzi).cet.ci << endl          << "Broj transakcije: " << FrontQ(Qbrzi).cet.di << endl          << "_____________________________________" << endl;     DeQueueQ(Qbrzi);   }   cout << endl; }  void brisi() {   queue Qp;   InitQ(Qp);   bool brisi, dob;    while(!IsEmptyQ(Q))   {     EnQueueQ(FrontQ(Q), Qp);     DeQueueQ(Q);   }    time_t t = time(0);   struct tm *now = localtime(&t);    InitQ(Q);   cout << "Stanje glavnog reda:" << endl;   while(!IsEmptyQ(Qp))   {     brisi = false;     dob = false;     if((now->tm_year+1900)-FrontQ(Qp).g < 30)       dob = true;     else if((now->tm_year+1900)-FrontQ(Qp).g == 30)     {       if(FrontQ(Qp).m > (now->tm_mon+1))         dob = true;       else if(FrontQ(Qp).m == (now->tm_mon+1))         if(FrontQ(Qp).d > now->tm_mday)           dob = true;     }      if(FrontQ(Qp).cet.ci==4 && FrontQ(Qp).cet.di==1 && FrontQ(Qp).tekuci<100 && dob)       brisi = true;     if(FrontQ(Qp).cet.ci==1 && FrontQ(Qp).cet.di==2 && FrontQ(Qp).tekuci>5000)       brisi = true;      if(!brisi)     {       cout << "Ime i prezime: " << FrontQ(Qp).prez_ime << endl            << "Broj prioriteta: " << FrontQ(Qp).cet.ci << endl            << "Broj transakcije: " << FrontQ(Qp).cet.di << endl;              cout.setf(ios::fixed, ios::floatfield); cout.precision(2);              cout << "Stanje tekuceg racuna: " << FrontQ(Qp).tekuci << endl;              cout.unsetf(ios::floatfield);        cout << "Datum rodjenja: " << FrontQ(Qp).d << "."            << FrontQ(Qp).m << "." << FrontQ(Qp).g << "." << endl            << "_____________________________________" << endl;       EnQueueQ(FrontQ(Qp), Q);     }     else       n--;     DeQueueQ(Qp);   }   cout << endl; }  void novi_open(int br_novi) {   static int index = 0;   static int brojac = 0;   static int mem;    mem = br_novi;   polje[index++] = FrontQ(Q);   brojac++;   DeQueueQ(Q);    while(!IsEmptyQ(Q))     novi_open(br_novi);    if(--mem >= 0)   {     brojac--;     cout << "Ime i prezime: " << polje[--index].prez_ime << endl;     return;   }    if(--brojac > 0)     return;      InitQ(Q);   cout << "Stanje u glavnom redu:" << endl;   for(int i=0; i<index; i++)   {     cout << "Ime i prezime: " << polje[i].prez_ime << endl;     EnQueueQ(polje[i], Q);   }    brojac = 0;   index = 0;      cout << endl; }  int main() {   int izbor;   float br_novi;    do   {     cout <<"==IZBORNIK==\n"<< "1. Dodavanje zapisa o klijentima banke u red" << endl          << "2. Simulacija reda brzih transakcija" << endl          << "3. Brisanje VIP klijenata (u-30 && uplata && tekuci<100) i "          << endl << "Umirovljenika (isplata && tekuci>5000)" << endl          << "4. Otvaranje novog saltera" << endl<<"9.Izlaz iz programa" << endl<<"Vas izbor: ";     cin >> izbor;     switch(izbor)     {       case 1:         cout << endl <<"1. Dodavanje zapisa o klijentima banke u red" << endl;           cout << "Niz od koliko cetvorki zelite generirati? ";           cin >> n;           generiranje(n);           zapisi(n);         break;       case 2:         cout << endl << "2. Simulacija reda brzih transakcija" << endl;         brzi_red();         break;       case 3:         cout << endl << "3. Brisanje VIP klijenata (u-30 && uplata && tekuci<100) i "              << endl << "Umirovljenika (isplata && tekuci>5000)" << endl;         brisi();         break;       case 4:         cout << endl << "4. Otvaranje novog saltera" << endl;         br_novi = 0.3*n;         polje = new klijent[n];         cout << "Stanje u novom redu:" << endl;         novi_open((int)br_novi);         delete [] polje;         break;       default:         cout << "Pogresan unos!" << endl << endl;     }   } while(izbor != 9);   return 0; }