Return to Snippet

Revision: 36442
at November 24, 2010 10:52 by FilipJ


Updated Code
#############################################################################
#################################red_polje.h################################# 
#############################################################################


#include<iostream>
using namespace std;

struct zapis{
       char prezime[20];
       char ime[20];
       int god;
       float stanje;
       char vrsta_transakcije;       
};

struct qu{
       zapis elements[10000];
       int front,rear;          
};

typedef qu red;

int AddOne(int n){
    return((n+1)%10000);    
}//fjas

zapis FrontQ(red *Q){ 
     if(AddOne((*Q).rear)==(*Q).front){
       cout << "Red je pun" << endl;                                
      } 
     return (*Q).elements[(*Q).front];     
}//fja

void EnQueueQ(zapis x, red *Q){
     (*Q).rear=AddOne((*Q).rear);
     (*Q).elements[(*Q).rear] = x;
}//fja

void DeQueueQ(red *Q){
     if(AddOne((*Q).rear)==(*Q).front){
       cout << "Red je pun" << endl;                                
      } 
	  (*Q).front=AddOne((*Q).front);
}//fja

void InitQ(red *Q){
    (*Q).rear=9999;
	(*Q).front=0;         
}//fja

bool IsEmptyQ(red *Q){
     if(AddOne((*Q).rear)==(*Q).front){
       return true;
       }
     else {
          return false;
          }
}//fja

#############################################################################
################################zadatak3.cpp################################# 
#############################################################################

#include<iostream>
#include "red_polje.h"
using namespace std;
zapis klijent;
int br=0;
void dodavanje_zapisa(qu *Q){
     cout << "Unesite ime: ";
     cin >> klijent.ime;
     cout << endl << "Unesite prezime: ";
     cin >> klijent.prezime;
     cout << endl << "Godina rodjenja: ";
     cin >> klijent.god;
     cout << endl << "Stanje na bankovnom racunu (kn): ";
     cin >> klijent.stanje;
     cout << endl << "Vrsta transakcije (u/i,p,k): ";
     cin >> klijent.vrsta_transakcije;
     cout << endl;
     EnQueueQ(klijent, Q);
     br++;      
}
void ispis(qu *Q, qu *trenutni){
    zapis klijent;
    while(!IsEmptyQ(Q)){
      klijent=FrontQ(Q);
      DeQueueQ(Q);
      cout << "Ime: " << klijent.ime << endl;
      cout << "Prezime: " << klijent.prezime << endl;
      cout << "Godiste: " << klijent.god << endl;
      cout << "Stanje na racunu: " << klijent.stanje << endl;
      cout << "Vrsta transakcije: " << klijent.vrsta_transakcije << endl;
      cout << "----------------------------" << endl;
      ///////
      EnQueueQ(klijent, trenutni);
    }//while
    while(!IsEmptyQ(trenutni)){
      klijent=FrontQ(trenutni);
      DeQueueQ(trenutni);
      EnQueueQ(klijent, Q);
     }//while
}//fja

void provjera(qu *Q, qu *trenutni){
     zapis pom;
     int jos=br;
     while(jos){ 
        pom=FrontQ(Q);
        DeQueueQ(Q);
        if(pom.god < 1945) {
         EnQueueQ(pom, Q); 
         }//if
        else {
         EnQueueQ(pom, trenutni); 
         }//else 
       jos--;               
      }//while
      while(!IsEmptyQ(trenutni)){
        pom=FrontQ(trenutni);
        DeQueueQ(trenutni);
        EnQueueQ(pom, Q);                 
       }//while
       ispis(Q,trenutni);     
}//fja

void brisanje(qu *Q, qu *trenutni){
     zapis klijent;
     int jos=br;
     while(jos){
       klijent=FrontQ(Q);
       DeQueueQ(Q);
       if(klijent.stanje > 100 || klijent.vrsta_transakcije=='u' || klijent.vrsta_transakcije=='p'){
         EnQueueQ(klijent, trenutni); 
         }//if
        jos--;                  
      }//while
      while(!IsEmptyQ(trenutni)){
        klijent=FrontQ(trenutni);
        DeQueueQ(trenutni);
        EnQueueQ(klijent, Q);                          
       }//while
        ispis(Q,trenutni);     
}//fja

void otvaranje_zatvaranje(qu *Q){
      zapis klijent;
      klijent=FrontQ(Q);
      DeQueueQ(Q);
      if(!IsEmptyQ(Q)){
       otvaranje_zatvaranje(Q); }//if
      EnQueueQ(klijent, Q);
}//fja

int main(){
int izbor;
qu q;
InitQ(&q);
qu trenutni;
InitQ(&trenutni);

cout << endl;
do{
    cout << "---------------IZBORNIK--------------" << endl;
    cout << "1. Dodavanje zapisa o klinetima u red" << endl;
    cout << "2. Ispis starijih od 65 na pocetak reda" << endl;
    cout << "3. Izbacivanje klijenata (stanje < 100kn)" << endl;
    cout << "4. Simulacija saltera u banci" << endl;
    cout << "9. Izlaz iz programa" << endl;
    cout << "--------------------------------------" << endl;
    cout << "Unesite vas izbor: ";
    cin >> izbor;
    cout << endl;
    switch(izbor){
                  case 1: 
                          dodavanje_zapisa(&q);
                          break;
                  case 2: provjera(&q,&trenutni);
                          break;
                  case 3: brisanje(&q,&trenutni);
                          break;
                  case 4: otvaranje_zatvaranje(&q);
                          ispis(&q,&trenutni);
                          break;
             
     }//switch
    }while(izbor!=9);    
system("PAUSE");
return 0;
}

Revision: 36441
at November 22, 2010 07:05 by FilipJ


Updated Code
#############################################################################
#################################red_polje.h################################# 
#############################################################################


#include<iostream>
using namespace std;

struct zapis{
       char prezime[20];
       char ime[20];
       int god;
       float stanje;
       char vrsta_transakcije;       
};

struct qu{
       zapis elements[10000];
       int front,rear;          
};

typedef qu red;

int AddOne(int n){
    return((n+1)%10000);    
}//fjas

zapis FrontQ(red *Q){ 
     if(AddOne((*Q).rear)==(*Q).front){
       cout << "Red je prazan" << endl;                                
      } 
     return (*Q).elements[(*Q).front];     
}//fja

void EnQueueQ(zapis x, red *Q){
     (*Q).rear=AddOne((*Q).rear);
     (*Q).elements[(*Q).rear] = x;
}//fja

void DeQueueQ(red *Q){
     if(AddOne((*Q).rear)==(*Q).front){
       cout << "Red je prazan" << endl;                                
      } 
	  (*Q).front=AddOne((*Q).front);
}//fja

void InitQ(red *Q){
    (*Q).rear=9999;
	(*Q).front=0;         
}//fja

bool IsEmptyQ(red *Q){
     if(AddOne((*Q).rear)==(*Q).front){
       return true;
       }
     else {
          return false;
          }
}//fja

#############################################################################
################################zadatak3.cpp################################# 
#############################################################################

#include<iostream>
#include "red_polje.h"
using namespace std;
zapis klijent;
int br=0;
void dodavanje_zapisa(qu *Q){
     cout << "Unesite ime: ";
     cin >> klijent.ime;
     cout << endl << "Unesite prezime: ";
     cin >> klijent.prezime;
     cout << endl << "Godina rodjenja: ";
     cin >> klijent.god;
     cout << endl << "Stanje na bankovnom racunu (kn): ";
     cin >> klijent.stanje;
     cout << endl << "Vrsta transakcije (u/i,p,k): ";
     cin >> klijent.vrsta_transakcije;
     cout << endl;
     EnQueueQ(klijent, Q);
     br++;      
}
void ispis(qu *Q, qu *trenutni){
    zapis klijent;
    while(!IsEmptyQ(Q)){
      klijent=FrontQ(Q);
      DeQueueQ(Q);
      cout << "Ime: " << klijent.ime << endl;
      cout << "Prezime: " << klijent.prezime << endl;
      cout << "Godiste: " << klijent.god << endl;
      cout << "Stanje na racunu: " << klijent.stanje << endl;
      cout << "Vrsta transakcije: " << klijent.vrsta_transakcije << endl;
      cout << "----------------------------" << endl;
      ///////
      EnQueueQ(klijent, trenutni);
    }//while
    while(!IsEmptyQ(trenutni)){
      klijent=FrontQ(trenutni);
      DeQueueQ(trenutni);
      EnQueueQ(klijent, Q);
     }//while
}//fja

void provjera(qu *Q, qu *trenutni){
     zapis pom;
     int jos=br;
     while(jos){ 
        pom=FrontQ(Q);
        DeQueueQ(Q);
        if(pom.god < 1945) {
         EnQueueQ(pom, Q); 
         }//if
        else {
         EnQueueQ(pom, trenutni); 
         }//else 
       jos--;               
      }//while
      while(!IsEmptyQ(trenutni)){
        pom=FrontQ(trenutni);
        DeQueueQ(trenutni);
        EnQueueQ(pom, Q);                 
       }//while
       ispis(Q,trenutni);     
}//fja

void brisanje(qu *Q, qu *trenutni){
     zapis klijent;
     int jos=br;
     while(jos){
       klijent=FrontQ(Q);
       DeQueueQ(Q);
       if(klijent.stanje > 100 || klijent.vrsta_transakcije=='u' || klijent.vrsta_transakcije=='p'){
         EnQueueQ(klijent, trenutni); 
         }//if
        jos--;                  
      }//while
      while(!IsEmptyQ(trenutni)){
        klijent=FrontQ(trenutni);
        DeQueueQ(trenutni);
        EnQueueQ(klijent, Q);                          
       }//while
        ispis(Q,trenutni);     
}//fja

void otvaranje_zatvaranje(qu *Q){
      zapis klijent;
      klijent=FrontQ(Q);
      DeQueueQ(Q);
      if(!IsEmptyQ(Q)){
       otvaranje_zatvaranje(Q); }//if
      EnQueueQ(klijent, Q);
}//fja

int main(){
int izbor;
qu q;
InitQ(&q);
qu trenutni;
InitQ(&trenutni);

cout << endl;
do{
    cout << "---------------IZBORNIK--------------" << endl;
    cout << "1. Dodavanje zapisa o klinetima u red" << endl;
    cout << "2. Ispis starijih od 65 na pocetak reda" << endl;
    cout << "3. Izbacivanje klijenata (stanje < 100kn)" << endl;
    cout << "4. Simulacija saltera u banci" << endl;
    cout << "9. Izlaz iz programa" << endl;
    cout << "--------------------------------------" << endl;
    cout << "Unesite vas izbor: ";
    cin >> izbor;
    cout << endl;
    switch(izbor){
                  case 1: 
                          dodavanje_zapisa(&q);
                          break;
                  case 2: provjera(&q,&trenutni);
                          break;
                  case 3: brisanje(&q,&trenutni);
                          break;
                  case 4: otvaranje_zatvaranje(&q);
                          ispis(&q,&trenutni);
                          break;
             
     }//switch
    }while(izbor!=9);    
system("PAUSE");
return 0;
}

Revision: 36440
at November 22, 2010 02:26 by FilipJ


Updated Code
#############################################################################
#################################red_polje.h################################# 
#############################################################################


#include<iostream>
using namespace std;

struct zapis{
       char prezime[20];
       char ime[20];
       int god;
       float stanje;
       char vrsta_transakcije;       
};

struct qu{
       zapis elements[10000];
       int front,rear;          
};

typedef qu red;

int AddOne(int n){
    return((n+1)%10000);    
}//fjas

zapis FrontQ(red *Q){ 
     if(AddOne((*Q).rear)==(*Q).front){
       cout << "Red je prazan" << endl;                                
      } 
     return (*Q).elements[(*Q).front];     
}//fja

void EnQueueQ(zapis x, red *Q){
     (*Q).rear=AddOne((*Q).rear);
     (*Q).elements[(*Q).rear] = x;
}//fja

void DeQueueQ(red *Q){
     if(AddOne((*Q).rear)==(*Q).front){
       cout << "Red je prazan" << endl;                                
      } 
	  (*Q).front=AddOne((*Q).front);
}//fja

void InitQ(red *Q){
    (*Q).rear=9999;
	(*Q).front=0;         
}//fja

bool IsEmptyQ(red *Q){
     if(AddOne((*Q).rear)==(*Q).front){
       return true;
       }
     else {
          return false;
          }
}//fja

#############################################################################
################################zadatak3.cpp################################# 
#############################################################################

#include<iostream>
#include "red_polje.h"
using namespace std;
zapis klijent;
int br=0;
void dodavanje_zapisa(qu *Q){
     cout << "Unesite ime: ";
     cin >> klijent.ime;
     cout << endl << "Unesite prezime: ";
     cin >> klijent.prezime;
     cout << endl << "Godina rodjenja: ";
     cin >> klijent.god;
     cout << endl << "Stanje na bankovnom racunu (kn): ";
     cin >> klijent.stanje;
     cout << endl << "Vrsta transakcije (u/i,p,k): ";
     cin >> klijent.vrsta_transakcije;
     cout << endl;
     EnQueueQ(klijent, Q);
     br++;      
}
void ispis(qu *Q, qu *trenutni){
    zapis klijent;
    while(!IsEmptyQ(Q)){
      klijent=FrontQ(Q);
      DeQueueQ(Q);
      cout << "Ime: " << klijent.ime << endl;
      cout << "Prezime: " << klijent.prezime << endl;
      cout << "Godiste: " << klijent.god << endl;
      cout << "Stanje na racunu: " << klijent.stanje << endl;
      cout << "Vrsta transakcije: " << klijent.vrsta_transakcije << endl;
      cout << "----------------------------" << endl;
      ///////
      EnQueueQ(klijent, trenutni);
    }//while
    while(!IsEmptyQ(trenutni)){
      klijent=FrontQ(trenutni);
      DeQueueQ(trenutni);
      EnQueueQ(klijent, Q);
     }//while
}//fja

void provjera(qu *Q, qu *trenutni){
     zapis pom;
     int jos=br;
     while(jos){ 
        pom=FrontQ(Q);
        DeQueueQ(Q);
        if(pom.god < 1945) {
         EnQueueQ(pom, Q); 
         }//if
        else {
         EnQueueQ(pom, trenutni); 
         }//else 
       jos--;               
      }//while
      while(!IsEmptyQ(trenutni)){
        pom=FrontQ(trenutni);
        DeQueueQ(trenutni);
        EnQueueQ(pom, Q);                 
       }//while
       ispis(Q,trenutni);     
}//fja

void brisanje(qu *Q, qu *trenutni){
     zapis klijent;
     int jos=br;
     while(jos){
       klijent=FrontQ(Q);
       DeQueueQ(Q);
       if(klijent.stanje > 100 || klijent.vrsta_transakcije=='u' || klijent.vrsta_transakcije=='p'){
         EnQueueQ(klijent, trenutni); 
         }//if
        jos--;                  
      }//while
      while(!IsEmptyQ(trenutni)){
        klijent=FrontQ(trenutni);
        DeQueueQ(trenutni);
        EnQueueQ(klijent, Q);                          
       }//while
        ispis(Q,trenutni);     
}//fja

void otvaranje_zatvaranje(qu *Q){
      zapis klijent;
      klijent=FrontQ(Q);
      DeQueueQ(Q);
      if(!IsEmptyQ(Q)){
       otvaranje_zatvaranje(Q); }//if
      EnQueueQ(klijent, Q);
}//fja

int main(){
int izbor;
qu q;
InitQ(&q);
qu trenutni;
InitQ(&trenutni);
cout << endl;
cout << "===================NAPOMENA=================" << endl;
cout << "Za svaku novu tocku (2,3,4), molim ponovo pokrenut program" << endl;
cout << "============================================" << endl;
cout << endl;
do{
    cout << "---------------IZBORNIK--------------" << endl;
    cout << "1. Dodavanje zapisa o klinetima u red" << endl;
    cout << "2. Ispis starijih od 65 na pocetak reda" << endl;
    cout << "3. Izbacivanje klijenata (stanje < 100kn)" << endl;
    cout << "4. Simulacija saltera u banci" << endl;
    cout << "9. Izlaz iz programa" << endl;
    cout << "--------------------------------------" << endl;
    cout << "Unesite vas izbor: ";
    cin >> izbor;
    cout << endl;
    switch(izbor){
                  case 1: 
                          dodavanje_zapisa(&q);
                          break;
                  case 2: provjera(&q,&trenutni);
                          break;
                  case 3: brisanje(&q,&trenutni);
                          break;
                  case 4: otvaranje_zatvaranje(&q);
                          ispis(&q,&trenutni);
                          break;
             
     }//switch
    }while(izbor!=9);    
system("PAUSE");
return 0;
}

Revision: 36439
at November 22, 2010 02:24 by FilipJ


Updated Code
#############################################################################
#############################################################################
//red_polje.h

#include<iostream>
using namespace std;

struct zapis{
       char prezime[20];
       char ime[20];
       int god;
       float stanje;
       char vrsta_transakcije;       
};

struct qu{
       zapis elements[10000];
       int front,rear;          
};

typedef qu red;

int AddOne(int n){
    return((n+1)%10000);    
}//fjas

zapis FrontQ(red *Q){ 
     if(AddOne((*Q).rear)==(*Q).front){
       cout << "Red je prazan" << endl;                                
      } 
     return (*Q).elements[(*Q).front];     
}//fja

void EnQueueQ(zapis x, red *Q){
     (*Q).rear=AddOne((*Q).rear);
     (*Q).elements[(*Q).rear] = x;
}//fja

void DeQueueQ(red *Q){
     if(AddOne((*Q).rear)==(*Q).front){
       cout << "Red je prazan" << endl;                                
      } 
	  (*Q).front=AddOne((*Q).front);
}//fja

void InitQ(red *Q){
    (*Q).rear=9999;
	(*Q).front=0;         
}//fja

bool IsEmptyQ(red *Q){
     if(AddOne((*Q).rear)==(*Q).front){
       return true;
       }
     else {
          return false;
          }
}//fja

#############################################################################
#############################################################################
//glavni program

#include<iostream>
#include "red_polje.h"
using namespace std;
zapis klijent;
int br=0;
void dodavanje_zapisa(qu *Q){
     cout << "Unesite ime: ";
     cin >> klijent.ime;
     cout << endl << "Unesite prezime: ";
     cin >> klijent.prezime;
     cout << endl << "Godina rodjenja: ";
     cin >> klijent.god;
     cout << endl << "Stanje na bankovnom racunu (kn): ";
     cin >> klijent.stanje;
     cout << endl << "Vrsta transakcije (u/i,p,k): ";
     cin >> klijent.vrsta_transakcije;
     cout << endl;
     EnQueueQ(klijent, Q);
     br++;      
}
void ispis(qu *Q, qu *trenutni){
    zapis klijent;
    while(!IsEmptyQ(Q)){
      klijent=FrontQ(Q);
      DeQueueQ(Q);
      cout << "Ime: " << klijent.ime << endl;
      cout << "Prezime: " << klijent.prezime << endl;
      cout << "Godiste: " << klijent.god << endl;
      cout << "Stanje na racunu: " << klijent.stanje << endl;
      cout << "Vrsta transakcije: " << klijent.vrsta_transakcije << endl;
      cout << "----------------------------" << endl;
      ///////
      EnQueueQ(klijent, trenutni);
    }//while
    while(!IsEmptyQ(trenutni)){
      klijent=FrontQ(trenutni);
      DeQueueQ(trenutni);
      EnQueueQ(klijent, Q);
     }//while
}//fja

void provjera(qu *Q, qu *trenutni){
     zapis pom;
     int jos=br;
     while(jos){ 
        pom=FrontQ(Q);
        DeQueueQ(Q);
        if(pom.god < 1945) {
         EnQueueQ(pom, Q); 
         }//if
        else {
         EnQueueQ(pom, trenutni); 
         }//else 
       jos--;               
      }//while
      while(!IsEmptyQ(trenutni)){
        pom=FrontQ(trenutni);
        DeQueueQ(trenutni);
        EnQueueQ(pom, Q);                 
       }//while
       ispis(Q,trenutni);     
}//fja

void brisanje(qu *Q, qu *trenutni){
     zapis klijent;
     int jos=br;
     while(jos){
       klijent=FrontQ(Q);
       DeQueueQ(Q);
       if(klijent.stanje > 100 || klijent.vrsta_transakcije=='u' || klijent.vrsta_transakcije=='p'){
         EnQueueQ(klijent, trenutni); 
         }//if
        jos--;                  
      }//while
      while(!IsEmptyQ(trenutni)){
        klijent=FrontQ(trenutni);
        DeQueueQ(trenutni);
        EnQueueQ(klijent, Q);                          
       }//while
        ispis(Q,trenutni);     
}//fja

void otvaranje_zatvaranje(qu *Q){
      zapis klijent;
      klijent=FrontQ(Q);
      DeQueueQ(Q);
      if(!IsEmptyQ(Q)){
       otvaranje_zatvaranje(Q); }//if
      EnQueueQ(klijent, Q);
}//fja

int main(){
int izbor;
qu q;
InitQ(&q);
qu trenutni;
InitQ(&trenutni);
cout << endl;
cout << "===================NAPOMENA=================" << endl;
cout << "Za svaku novu tocku (2,3,4), molim ponovo pokrenut program" << endl;
cout << "============================================" << endl;
cout << endl;
do{
    cout << "---------------IZBORNIK--------------" << endl;
    cout << "1. Dodavanje zapisa o klinetima u red" << endl;
    cout << "2. Ispis starijih od 65 na pocetak reda" << endl;
    cout << "3. Izbacivanje klijenata (stanje < 100kn)" << endl;
    cout << "4. Simulacija saltera u banci" << endl;
    cout << "9. Izlaz iz programa" << endl;
    cout << "--------------------------------------" << endl;
    cout << "Unesite vas izbor: ";
    cin >> izbor;
    cout << endl;
    switch(izbor){
                  case 1: 
                          dodavanje_zapisa(&q);
                          break;
                  case 2: provjera(&q,&trenutni);
                          break;
                  case 3: brisanje(&q,&trenutni);
                          break;
                  case 4: otvaranje_zatvaranje(&q);
                          ispis(&q,&trenutni);
                          break;
             
     }//switch
    }while(izbor!=9);    
system("PAUSE");
return 0;
}

Revision: 36438
at November 22, 2010 02:23 by FilipJ


Updated Code
#
#############################################################################
#
#############################################################################
#
//red_polje.h

#include<iostream>
using namespace std;

struct zapis{
       char prezime[20];
       char ime[20];
       int god;
       float stanje;
       char vrsta_transakcije;       
};

struct qu{
       zapis elements[10000];
       int front,rear;          
};

typedef qu red;

int AddOne(int n){
    return((n+1)%10000);    
}//fjas

zapis FrontQ(red *Q){ 
     if(AddOne((*Q).rear)==(*Q).front){
       cout << "Red je prazan" << endl;                                
      } 
     return (*Q).elements[(*Q).front];     
}//fja

void EnQueueQ(zapis x, red *Q){
     (*Q).rear=AddOne((*Q).rear);
     (*Q).elements[(*Q).rear] = x;
}//fja

void DeQueueQ(red *Q){
     if(AddOne((*Q).rear)==(*Q).front){
       cout << "Red je prazan" << endl;                                
      } 
	  (*Q).front=AddOne((*Q).front);
}//fja

void InitQ(red *Q){
    (*Q).rear=9999;
	(*Q).front=0;         
}//fja

bool IsEmptyQ(red *Q){
     if(AddOne((*Q).rear)==(*Q).front){
       return true;
       }
     else {
          return false;
          }
}//fja

#############################################################################
#############################################################################
//glavni program

#include<iostream>
#include "red_polje.h"
using namespace std;
zapis klijent;
int br=0;
void dodavanje_zapisa(qu *Q){
     cout << "Unesite ime: ";
     cin >> klijent.ime;
     cout << endl << "Unesite prezime: ";
     cin >> klijent.prezime;
     cout << endl << "Godina rodjenja: ";
     cin >> klijent.god;
     cout << endl << "Stanje na bankovnom racunu (kn): ";
     cin >> klijent.stanje;
     cout << endl << "Vrsta transakcije (u/i,p,k): ";
     cin >> klijent.vrsta_transakcije;
     cout << endl;
     EnQueueQ(klijent, Q);
     br++;      
}
void ispis(qu *Q, qu *trenutni){
    zapis klijent;
    while(!IsEmptyQ(Q)){
      klijent=FrontQ(Q);
      DeQueueQ(Q);
      cout << "Ime: " << klijent.ime << endl;
      cout << "Prezime: " << klijent.prezime << endl;
      cout << "Godiste: " << klijent.god << endl;
      cout << "Stanje na racunu: " << klijent.stanje << endl;
      cout << "Vrsta transakcije: " << klijent.vrsta_transakcije << endl;
      cout << "----------------------------" << endl;
      ///////
      EnQueueQ(klijent, trenutni);
    }//while
    while(!IsEmptyQ(trenutni)){
      klijent=FrontQ(trenutni);
      DeQueueQ(trenutni);
      EnQueueQ(klijent, Q);
     }//while
}//fja

void provjera(qu *Q, qu *trenutni){
     zapis pom;
     int jos=br;
     while(jos){ 
        pom=FrontQ(Q);
        DeQueueQ(Q);
        if(pom.god < 1945) {
         EnQueueQ(pom, Q); 
         }//if
        else {
         EnQueueQ(pom, trenutni); 
         }//else 
       jos--;               
      }//while
      while(!IsEmptyQ(trenutni)){
        pom=FrontQ(trenutni);
        DeQueueQ(trenutni);
        EnQueueQ(pom, Q);                 
       }//while
       ispis(Q,trenutni);     
}//fja

void brisanje(qu *Q, qu *trenutni){
     zapis klijent;
     int jos=br;
     while(jos){
       klijent=FrontQ(Q);
       DeQueueQ(Q);
       if(klijent.stanje > 100 || klijent.vrsta_transakcije=='u' || klijent.vrsta_transakcije=='p'){
         EnQueueQ(klijent, trenutni); 
         }//if
        jos--;                  
      }//while
      while(!IsEmptyQ(trenutni)){
        klijent=FrontQ(trenutni);
        DeQueueQ(trenutni);
        EnQueueQ(klijent, Q);                          
       }//while
        ispis(Q,trenutni);     
}//fja

void otvaranje_zatvaranje(qu *Q){
      zapis klijent;
      klijent=FrontQ(Q);
      DeQueueQ(Q);
      if(!IsEmptyQ(Q)){
       otvaranje_zatvaranje(Q); }//if
      EnQueueQ(klijent, Q);
}//fja

int main(){
int izbor;
qu q;
InitQ(&q);
qu trenutni;
InitQ(&trenutni);
cout << endl;
cout << "===================NAPOMENA=================" << endl;
cout << "Za svaku novu tocku (2,3,4), molim ponovo pokrenut program" << endl;
cout << "============================================" << endl;
cout << endl;
do{
    cout << "---------------IZBORNIK--------------" << endl;
    cout << "1. Dodavanje zapisa o klinetima u red" << endl;
    cout << "2. Ispis starijih od 65 na pocetak reda" << endl;
    cout << "3. Izbacivanje klijenata (stanje < 100kn)" << endl;
    cout << "4. Simulacija saltera u banci" << endl;
    cout << "9. Izlaz iz programa" << endl;
    cout << "--------------------------------------" << endl;
    cout << "Unesite vas izbor: ";
    cin >> izbor;
    cout << endl;
    switch(izbor){
                  case 1: 
                          dodavanje_zapisa(&q);
                          break;
                  case 2: provjera(&q,&trenutni);
                          break;
                  case 3: brisanje(&q,&trenutni);
                          break;
                  case 4: otvaranje_zatvaranje(&q);
                          ispis(&q,&trenutni);
                          break;
             
     }//switch
    }while(izbor!=9);    
system("PAUSE");
return 0;
}

Revision: 36437
at November 22, 2010 02:22 by FilipJ


Updated Code
#include<iostream>
using namespace std;

struct zapis{
       char prezime[20];
       char ime[20];
       int god;
       float stanje;
       char vrsta_transakcije;       
};

struct qu{
       zapis elements[10000];
       int front,rear;          
};

typedef qu red;

int AddOne(int n){
    return((n+1)%10000);    
}//fjas

zapis FrontQ(red *Q){ 
     if(AddOne((*Q).rear)==(*Q).front){
       cout << "Red je prazan" << endl;                                
      } 
     return (*Q).elements[(*Q).front];     
}//fja

void EnQueueQ(zapis x, red *Q){
     (*Q).rear=AddOne((*Q).rear);
     (*Q).elements[(*Q).rear] = x;
}//fja

void DeQueueQ(red *Q){
     if(AddOne((*Q).rear)==(*Q).front){
       cout << "Red je prazan" << endl;                                
      } 
	  (*Q).front=AddOne((*Q).front);
}//fja

void InitQ(red *Q){
    (*Q).rear=9999;
	(*Q).front=0;         
}//fja

bool IsEmptyQ(red *Q){
     if(AddOne((*Q).rear)==(*Q).front){
       return true;
       }
     else {
          return false;
          }
}//fja

#############################################################################
#############################################################################
//glavni program

#include<iostream>
#include "red_polje.h"
using namespace std;
zapis klijent;
int br=0;
void dodavanje_zapisa(qu *Q){
     cout << "Unesite ime: ";
     cin >> klijent.ime;
     cout << endl << "Unesite prezime: ";
     cin >> klijent.prezime;
     cout << endl << "Godina rodjenja: ";
     cin >> klijent.god;
     cout << endl << "Stanje na bankovnom racunu (kn): ";
     cin >> klijent.stanje;
     cout << endl << "Vrsta transakcije (u/i,p,k): ";
     cin >> klijent.vrsta_transakcije;
     cout << endl;
     EnQueueQ(klijent, Q);
     br++;      
}
void ispis(qu *Q, qu *trenutni){
    zapis klijent;
    while(!IsEmptyQ(Q)){
      klijent=FrontQ(Q);
      DeQueueQ(Q);
      cout << "Ime: " << klijent.ime << endl;
      cout << "Prezime: " << klijent.prezime << endl;
      cout << "Godiste: " << klijent.god << endl;
      cout << "Stanje na racunu: " << klijent.stanje << endl;
      cout << "Vrsta transakcije: " << klijent.vrsta_transakcije << endl;
      cout << "----------------------------" << endl;
      ///////
      EnQueueQ(klijent, trenutni);
    }//while
    while(!IsEmptyQ(trenutni)){
      klijent=FrontQ(trenutni);
      DeQueueQ(trenutni);
      EnQueueQ(klijent, Q);
     }//while
}//fja

void provjera(qu *Q, qu *trenutni){
     zapis pom;
     int jos=br;
     while(jos){ 
        pom=FrontQ(Q);
        DeQueueQ(Q);
        if(pom.god < 1945) {
         EnQueueQ(pom, Q); 
         }//if
        else {
         EnQueueQ(pom, trenutni); 
         }//else 
       jos--;               
      }//while
      while(!IsEmptyQ(trenutni)){
        pom=FrontQ(trenutni);
        DeQueueQ(trenutni);
        EnQueueQ(pom, Q);                 
       }//while
       ispis(Q,trenutni);     
}//fja

void brisanje(qu *Q, qu *trenutni){
     zapis klijent;
     int jos=br;
     while(jos){
       klijent=FrontQ(Q);
       DeQueueQ(Q);
       if(klijent.stanje > 100 || klijent.vrsta_transakcije=='u' || klijent.vrsta_transakcije=='p'){
         EnQueueQ(klijent, trenutni); 
         }//if
        jos--;                  
      }//while
      while(!IsEmptyQ(trenutni)){
        klijent=FrontQ(trenutni);
        DeQueueQ(trenutni);
        EnQueueQ(klijent, Q);                          
       }//while
        ispis(Q,trenutni);     
}//fja

void otvaranje_zatvaranje(qu *Q){
      zapis klijent;
      klijent=FrontQ(Q);
      DeQueueQ(Q);
      if(!IsEmptyQ(Q)){
       otvaranje_zatvaranje(Q); }//if
      EnQueueQ(klijent, Q);
}//fja

int main(){
int izbor;
qu q;
InitQ(&q);
qu trenutni;
InitQ(&trenutni);
cout << endl;
cout << "===================NAPOMENA=================" << endl;
cout << "Za svaku novu tocku (2,3,4), molim ponovo pokrenut program" << endl;
cout << "============================================" << endl;
cout << endl;
do{
    cout << "---------------IZBORNIK--------------" << endl;
    cout << "1. Dodavanje zapisa o klinetima u red" << endl;
    cout << "2. Ispis starijih od 65 na pocetak reda" << endl;
    cout << "3. Izbacivanje klijenata (stanje < 100kn)" << endl;
    cout << "4. Simulacija saltera u banci" << endl;
    cout << "9. Izlaz iz programa" << endl;
    cout << "--------------------------------------" << endl;
    cout << "Unesite vas izbor: ";
    cin >> izbor;
    cout << endl;
    switch(izbor){
                  case 1: 
                          dodavanje_zapisa(&q);
                          break;
                  case 2: provjera(&q,&trenutni);
                          break;
                  case 3: brisanje(&q,&trenutni);
                          break;
                  case 4: otvaranje_zatvaranje(&q);
                          ispis(&q,&trenutni);
                          break;
             
     }//switch
    }while(izbor!=9);    
system("PAUSE");
return 0;
}

Revision: 36436
at November 22, 2010 01:30 by FilipJ


Updated Code
#include<iostream>
using namespace std;

struct zapis{
       char prezime[20];
       char ime[20];
       int god;
       float stanje;
       char vrsta_transakcije;       
};

struct qu{
       zapis elements[10000];
       int front,rear;          
};

typedef qu red;

int AddOne(int n){
    return((n+1)%10000);    
}//fjas

zapis FrontQ(red *Q){ 
     if(AddOne((*Q).rear)==(*Q).front){
       cout << "Red je prazan" << endl;                                
      } 
     return (*Q).elements[(*Q).front];     
}//fja

void EnQueueQ(zapis x, red *Q){
     (*Q).rear=AddOne((*Q).rear);
     (*Q).elements[(*Q).rear] = x;
}//fja

void DeQueueQ(red *Q){
     if(AddOne((*Q).rear)==(*Q).front){
       cout << "Red je prazan" << endl;                                
      } 
	  (*Q).front=AddOne((*Q).front);
}//fja

void InitQ(red *Q){
    (*Q).rear=9999;
	(*Q).front=0;         
}//fja

bool IsEmptyQ(red *Q){
     if(AddOne((*Q).rear)==(*Q).front){
       return true;
       }
     else {
          return false;
          }
}//fja

#############################################################################
#############################################################################
//glavni program

#include<iostream>
#include "red_polje.h"
using namespace std;
zapis klijent;
int br=0;
void dodavanje_zapisa(qu *Q){
     cout << "Unesite ime: ";
     cin >> klijent.ime;
     cout << endl << "Unesite prezime: ";
     cin >> klijent.prezime;
     cout << endl << "Godina rodjenja: ";
     cin >> klijent.god;
     cout << endl << "Stanje na bankovnom racunu (kn): ";
     cin >> klijent.stanje;
     cout << endl << "Vrsta transakcije (u/i,p,k): ";
     cin >> klijent.vrsta_transakcije;
     cout << endl;
     EnQueueQ(klijent, Q);
     br++;      
}
void ispis(qu *Q){
    zapis klijent;
    while(!IsEmptyQ(Q)){
      klijent=FrontQ(Q);
      DeQueueQ(Q);
      cout << "Ime: " << klijent.ime << endl;
      cout << "Prezime: " << klijent.prezime << endl;
      cout << "Godiste: " << klijent.god << endl;
      cout << "Stanje na racunu: " << klijent.stanje << endl;
      cout << "Vrsta transakcije: " << klijent.vrsta_transakcije << endl;
      cout << "----------------------------" << endl;
    }//while
}//fja

void provjera(qu *Q, qu *trenutni){
     zapis pom;
     int jos=br;
     while(jos){ //dok ima zapisa
        pom=FrontQ(Q);
        DeQueueQ(Q);
        if(pom.god < 1945) {
         EnQueueQ(pom, Q); 
         }//if
        else {
         EnQueueQ(pom, trenutni); 
         }//else 
       jos--;               
      }//while
      while(!IsEmptyQ(trenutni)){
        pom=FrontQ(trenutni);
        DeQueueQ(trenutni);
        EnQueueQ(pom, Q);                 
       }//while
       ispis(Q);     
}//fja

void brisanje(qu *Q, qu *trenutni){
     zapis klijent;
     int jos=br;
     while(jos){
       klijent=FrontQ(Q);
       DeQueueQ(Q);
       if(klijent.stanje > 100 || klijent.vrsta_transakcije=='u' || klijent.vrsta_transakcije=='p'){
         EnQueueQ(klijent, trenutni); 
         }//if
        jos--;                  
      }//while
      while(!IsEmptyQ(trenutni)){
        klijent=FrontQ(trenutni);
        DeQueueQ(trenutni);
        EnQueueQ(klijent, Q);                          
       }//while
        ispis(Q);     
}//fja

void otvaranje_zatvaranje(qu *Q){
      zapis klijent;
      klijent=FrontQ(Q);
      DeQueueQ(Q);
      if(!IsEmptyQ(Q)){
       otvaranje_zatvaranje(Q); }//if
      EnQueueQ(klijent, Q);
}//fja

int main(){
int izbor;
qu q;
InitQ(&q);
qu trenutni;
InitQ(&trenutni);
cout << endl;
cout << "===================NAPOMENA=================" << endl;
cout << "Za svaku novu tocku (2,3,4), molim ponovo pokrenut program" << endl;
cout << "============================================" << endl;
cout << endl;
do{
    cout << "---------------IZBORNIK--------------" << endl;
    cout << "1. Dodavanje zapisa o klinetima u red" << endl;
    cout << "2. Ispis starijih od 65 na pocetak reda" << endl;
    cout << "3. Izbacivanje klijenata (stanje < 100kn)" << endl;
    cout << "4. Simulacija saltera u banci" << endl;
    cout << "9. Izlaz iz programa" << endl;
    cout << "--------------------------------------" << endl;
    cout << "Unesite vas izbor: ";
    cin >> izbor;
    cout << endl;
    switch(izbor){
                  case 1: 
                          dodavanje_zapisa(&q);
                          break;
                  case 2: provjera(&q,&trenutni);
                          break;
                  case 3: brisanje(&q,&trenutni);
                          break;
                  case 4: otvaranje_zatvaranje(&q);
                          ispis(&q);
                          break;
             
     }//switch
    }while(izbor!=9);    
system("PAUSE");
return 0;
}

Revision: 36435
at November 22, 2010 01:29 by FilipJ


Updated Code
#include<iostream>
using namespace std;

struct zapis{
       char prezime[20];
       char ime[20];
       int god;
       float stanje;
       char vrsta_transakcije;       
};

struct qu{
       zapis elements[10000];
       int front,rear; //FRONT prvi izlazi, REAR upisuje (ulazi) se prvi              
};

typedef qu red;

int AddOne(int n){
    return((n+1)%10000);    
}//fjas

zapis FrontQ(red *Q){ //vraca vrijednost prvo na redu
     if(AddOne((*Q).rear)==(*Q).front){
       cout << "Red je prazan" << endl;                                
      } 
     return (*Q).elements[(*Q).front];     
}//fja

void EnQueueQ(zapis x, red *Q){
     (*Q).rear=AddOne((*Q).rear);
     (*Q).elements[(*Q).rear] = x;
}//fja

void DeQueueQ(red *Q){
     if(AddOne((*Q).rear)==(*Q).front){
       cout << "Red je prazan" << endl;                                
      } 
	  (*Q).front=AddOne((*Q).front); //Addone -> jer po��inje od praznog elementa
}//fja

void InitQ(red *Q){
    (*Q).rear=9999;
	(*Q).front=0;         
}//fja

bool IsEmptyQ(red *Q){
     if(AddOne((*Q).rear)==(*Q).front){
       return true;
       }
     else {
          return false;
          }
}//fja

#############################################################################
#############################################################################
//glavni program

#include<iostream>
#include "red_polje.h"
using namespace std;
zapis klijent;
int br=0;
void dodavanje_zapisa(qu *Q){
     cout << "Unesite ime: ";
     cin >> klijent.ime;
     cout << endl << "Unesite prezime: ";
     cin >> klijent.prezime;
     cout << endl << "Godina rodjenja: ";
     cin >> klijent.god;
     cout << endl << "Stanje na bankovnom racunu (kn): ";
     cin >> klijent.stanje;
     cout << endl << "Vrsta transakcije (u/i,p,k): ";
     cin >> klijent.vrsta_transakcije;
     cout << endl;
     EnQueueQ(klijent, Q);
     br++;      
}
void ispis(qu *Q){
    zapis klijent;
    while(!IsEmptyQ(Q)){
      klijent=FrontQ(Q);
      DeQueueQ(Q);
      cout << "Ime: " << klijent.ime << endl;
      cout << "Prezime: " << klijent.prezime << endl;
      cout << "Godiste: " << klijent.god << endl;
      cout << "Stanje na racunu: " << klijent.stanje << endl;
      cout << "Vrsta transakcije: " << klijent.vrsta_transakcije << endl;
      cout << "----------------------------" << endl;
    }//while
}//fja

void provjera(qu *Q, qu *trenutni){
     zapis pom;
     int jos=br;
     while(jos){ //dok ima zapisa
        pom=FrontQ(Q);
        DeQueueQ(Q);
        if(pom.god < 1945) {
         EnQueueQ(pom, Q); 
         }//if
        else {
         EnQueueQ(pom, trenutni); 
         }//else 
       jos--;               
      }//while
      while(!IsEmptyQ(trenutni)){
        pom=FrontQ(trenutni);
        DeQueueQ(trenutni);
        EnQueueQ(pom, Q);                 
       }//while
       ispis(Q);     
}//fja

void brisanje(qu *Q, qu *trenutni){
     zapis klijent;
     int jos=br;
     while(jos){
       klijent=FrontQ(Q);
       DeQueueQ(Q);
       if(klijent.stanje > 100 || klijent.vrsta_transakcije=='u' || klijent.vrsta_transakcije=='p'){
         EnQueueQ(klijent, trenutni); 
         }//if
        jos--;                  
      }//while
      while(!IsEmptyQ(trenutni)){
        klijent=FrontQ(trenutni);
        DeQueueQ(trenutni);
        EnQueueQ(klijent, Q);                          
       }//while
        ispis(Q);     
}//fja

void otvaranje_zatvaranje(qu *Q){
      zapis klijent;
      klijent=FrontQ(Q);
      DeQueueQ(Q);
      if(!IsEmptyQ(Q)){
       otvaranje_zatvaranje(Q); }//if
      EnQueueQ(klijent, Q);
}//fja

int main(){
int izbor;
qu q;
InitQ(&q);
qu trenutni;
InitQ(&trenutni);
cout << endl;
cout << "===================NAPOMENA=================" << endl;
cout << "Za svaku novu tocku (2,3,4), molim ponovo pokrenut program" << endl;
cout << "============================================" << endl;
cout << endl;
do{
    cout << "---------------IZBORNIK--------------" << endl;
    cout << "1. Dodavanje zapisa o klinetima u red" << endl;
    cout << "2. Ispis starijih od 65 na pocetak reda" << endl;
    cout << "3. Izbacivanje klijenata (stanje < 100kn)" << endl;
    cout << "4. Simulacija saltera u banci" << endl;
    cout << "9. Izlaz iz programa" << endl;
    cout << "--------------------------------------" << endl;
    cout << "Unesite vas izbor: ";
    cin >> izbor;
    cout << endl;
    switch(izbor){
                  case 1: 
                          dodavanje_zapisa(&q);
                          break;
                  case 2: provjera(&q,&trenutni);
                          break;
                  case 3: brisanje(&q,&trenutni);
                          break;
                  case 4: otvaranje_zatvaranje(&q);
                          ispis(&q);
                          break;
             
     }//switch
    }while(izbor!=9);    
system("PAUSE");
return 0;
}

Revision: 36434
at November 22, 2010 01:28 by FilipJ


Updated Code
#include<iostream>
using namespace std;

struct zapis{
       char prezime[20];
       char ime[20];
       int god;
       float stanje;
       char vrsta_transakcije;       
};

struct qu{
       zapis elements[10000];
       int front,rear; //FRONT prvi izlazi, REAR upisuje (ulazi) se prvi              
};

typedef qu red;

int AddOne(int n){
    return((n+1)%10000);    
}//fjas

zapis FrontQ(red *Q){ //vraca vrijednost prvo na redu
     if(AddOne((*Q).rear)==(*Q).front){
       cout << "Red je prazan" << endl;                                
      } 
     return (*Q).elements[(*Q).front];     
}//fja

void EnQueueQ(zapis x, red *Q){
     (*Q).rear=AddOne((*Q).rear);
     (*Q).elements[(*Q).rear] = x;
}//fja

void DeQueueQ(red *Q){
     if(AddOne((*Q).rear)==(*Q).front){
       cout << "Red je prazan" << endl;                                
      } 
	  (*Q).front=AddOne((*Q).front); //Addone -> jer po�inje od praznog elementa
}//fja

void InitQ(red *Q){
    (*Q).rear=9999;
	(*Q).front=0;         
}//fja

bool IsEmptyQ(red *Q){
     if(AddOne((*Q).rear)==(*Q).front){
       return true;
       }
     else {
          return false;
          }
}//fja

//glavni program

#include<iostream>
#include "red_polje.h"
using namespace std;
zapis klijent;
int br=0;
void dodavanje_zapisa(qu *Q){
     cout << "Unesite ime: ";
     cin >> klijent.ime;
     cout << endl << "Unesite prezime: ";
     cin >> klijent.prezime;
     cout << endl << "Godina rodjenja: ";
     cin >> klijent.god;
     cout << endl << "Stanje na bankovnom racunu (kn): ";
     cin >> klijent.stanje;
     cout << endl << "Vrsta transakcije (u/i,p,k): ";
     cin >> klijent.vrsta_transakcije;
     cout << endl;
     EnQueueQ(klijent, Q);
     br++;      
}
void ispis(qu *Q){
    zapis klijent;
    while(!IsEmptyQ(Q)){
      klijent=FrontQ(Q);
      DeQueueQ(Q);
      cout << "Ime: " << klijent.ime << endl;
      cout << "Prezime: " << klijent.prezime << endl;
      cout << "Godiste: " << klijent.god << endl;
      cout << "Stanje na racunu: " << klijent.stanje << endl;
      cout << "Vrsta transakcije: " << klijent.vrsta_transakcije << endl;
      cout << "----------------------------" << endl;
    }//while
}//fja

void provjera(qu *Q, qu *trenutni){
     zapis pom;
     int jos=br;
     while(jos){ //dok ima zapisa
        pom=FrontQ(Q);
        DeQueueQ(Q);
        if(pom.god < 1945) {
         EnQueueQ(pom, Q); 
         }//if
        else {
         EnQueueQ(pom, trenutni); 
         }//else 
       jos--;               
      }//while
      while(!IsEmptyQ(trenutni)){
        pom=FrontQ(trenutni);
        DeQueueQ(trenutni);
        EnQueueQ(pom, Q);                 
       }//while
       ispis(Q);     
}//fja

void brisanje(qu *Q, qu *trenutni){
     zapis klijent;
     int jos=br;
     while(jos){
       klijent=FrontQ(Q);
       DeQueueQ(Q);
       if(klijent.stanje > 100 || klijent.vrsta_transakcije=='u' || klijent.vrsta_transakcije=='p'){
         EnQueueQ(klijent, trenutni); 
         }//if
        jos--;                  
      }//while
      while(!IsEmptyQ(trenutni)){
        klijent=FrontQ(trenutni);
        DeQueueQ(trenutni);
        EnQueueQ(klijent, Q);                          
       }//while
        ispis(Q);     
}//fja

void otvaranje_zatvaranje(qu *Q){
      zapis klijent;
      klijent=FrontQ(Q);
      DeQueueQ(Q);
      if(!IsEmptyQ(Q)){
       otvaranje_zatvaranje(Q); }//if
      EnQueueQ(klijent, Q);
}//fja

int main(){
int izbor;
qu q;
InitQ(&q);
qu trenutni;
InitQ(&trenutni);
cout << endl;
cout << "===================NAPOMENA=================" << endl;
cout << "Za svaku novu tocku (2,3,4), molim ponovo pokrenut program" << endl;
cout << "============================================" << endl;
cout << endl;
do{
    cout << "---------------IZBORNIK--------------" << endl;
    cout << "1. Dodavanje zapisa o klinetima u red" << endl;
    cout << "2. Ispis starijih od 65 na pocetak reda" << endl;
    cout << "3. Izbacivanje klijenata (stanje < 100kn)" << endl;
    cout << "4. Simulacija saltera u banci" << endl;
    cout << "9. Izlaz iz programa" << endl;
    cout << "--------------------------------------" << endl;
    cout << "Unesite vas izbor: ";
    cin >> izbor;
    cout << endl;
    switch(izbor){
                  case 1: 
                          dodavanje_zapisa(&q);
                          break;
                  case 2: provjera(&q,&trenutni);
                          break;
                  case 3: brisanje(&q,&trenutni);
                          break;
                  case 4: otvaranje_zatvaranje(&q);
                          ispis(&q);
                          break;
             
     }//switch
    }while(izbor!=9);    
system("PAUSE");
return 0;
}

Revision: 36433
at November 22, 2010 01:26 by FilipJ


Initial Code
#include<iostream>
using namespace std;

struct zapis{
       char prezime[20];
       char ime[20];
       int god;
       float stanje;
       char vrsta_transakcije;       
};

struct qu{
       zapis elements[10000];
       int front,rear; //FRONT prvi izlazi, REAR upisuje (ulazi) se prvi              
};

typedef qu red;

int AddOne(int n){
    return((n+1)%10000);    
}//fjas

zapis FrontQ(red *Q){ //vraca vrijednost prvo na redu
     if(AddOne((*Q).rear)==(*Q).front){
       cout << "Red je prazan" << endl;                                
      } 
     return (*Q).elements[(*Q).front];     
}//fja

void EnQueueQ(zapis x, red *Q){
     (*Q).rear=AddOne((*Q).rear);
     (*Q).elements[(*Q).rear] = x;
}//fja

void DeQueueQ(red *Q){
     if(AddOne((*Q).rear)==(*Q).front){
       cout << "Red je prazan" << endl;                                
      } 
	  (*Q).front=AddOne((*Q).front); //Addone -> jer počinje od praznog elementa
}//fja

void InitQ(red *Q){
    (*Q).rear=9999;
	(*Q).front=0;         
}//fja

bool IsEmptyQ(red *Q){
     if(AddOne((*Q).rear)==(*Q).front){
       return true;
       }
     else {
          return false;
          }
}//fja

Initial URL


Initial Description


Initial Title
zadatak_3_strukture_podataka

Initial Tags
3

Initial Language
C++