Return to Snippet

Revision: 53782
at December 2, 2011 20:08 by mgovedic


Initial Code
#include<iostream>
using namespace std;

struct podaci{
       int a,b,c,d;
};
struct red{
       podaci brojevi;
       red *sljedeci;
};
struct reda{
       red *front, *rear;
};


reda *InitQ(reda *Q){
     red *novi=new red;
     Q=new reda;
     Q->front=novi;
     Q->rear=novi;
     novi->sljedeci=NULL;
     return Q;
}

podaci FrontQ(reda *Q){
       return Q->front->sljedeci->brojevi;  
}
void EnQueueQ(podaci x, reda *Q){
     red *novi=new red;
     novi->brojevi=x;
     Q->rear->sljedeci=novi;
     novi->sljedeci=NULL;
     Q->rear=novi;
}
void DeQueueQ(reda *Q){
     if(Q->front != Q->rear){
                 red *brisi=Q->front;
                 Q->front=brisi->sljedeci;
                 delete brisi;
                 }
     else 
     cout<<"red je prazan"<<endl;
}
bool IsEmptyQ(reda *Q){
     if(Q->front==Q->rear) return 1;
     else return 0;
}

Initial URL

                                

Initial Description
zadatak 3

Initial Title
red_pokazivaci.h

Initial Tags
podataka

Initial Language
C++