Return to Snippet

Revision: 36457
at November 22, 2010 03:00 by maserdare


Initial Code
#include<iostream>
using namespace std;
 
struct klijent{
       char prez_ime[50]; 
       char transakcija[50];
       int god;
       double stanje;
};
 
struct tred{
       klijent klijenti;
       tred *sljedeci;
       tred *rear;
};
 
typedef struct tred *red;
 
tred *Q = new tred;
tred *Pom = new tred;
 
bool IsEmptyQ(tred *Qu){
     return Qu->sljedeci==NULL;
}
 
klijent FrontQ(tred *Qu){
        if(IsEmptyQ(Qu)) cout << endl << "Red je prazan! " << endl;
        else{
             tred *front = Qu->sljedeci;
            return front->klijenti;
        }
}
 
void EnQueueQ(klijent element, tred *Qu){
                      tred *novi = new tred, *zadnji = Qu->rear;
                      novi -> klijenti = element;
                      novi -> sljedeci = NULL;
                      if(IsEmptyQ(Qu))
                                   Qu->sljedeci = novi;
                      else
                           zadnji->sljedeci = novi;
                      Qu->rear = novi;
}
 
void DeQueueQ(tred *Qu){
     if(IsEmptyQ(Qu)) cout << endl << "Red je prazan! " << endl;
        else{
              tred *sljedeci = Qu->sljedeci, *front = sljedeci->sljedeci;
              delete sljedeci;
              Qu->sljedeci = front;
        }
}
 
void InitQ(tred *Qu){
           Qu->sljedeci = NULL;
           Qu->rear = NULL;
}

Initial URL

                                

Initial Description

                                

Initial Title
red_pokazivaci.h

Initial Tags

                                

Initial Language
C++