Return to Snippet

Revision: 36317
at November 20, 2010 10:59 by majstorica


Initial Code
struct klijent{
       char ime[20],prezime[20];
       int godina, stanje, trans;       
};

typedef klijent elementtype; 
struct qu {
	elementtype value;
	struct qu *next,*front,*rear;
};


void InitQ(qu *Q) {
    qu *pom;
	pom = new qu;
    (*Q).front=pom;
    (*Q).rear=pom;
    (*pom).next=NULL;
}

void EnqueueQ( elementtype x,qu *Q) { 
	qu *e;
	e=new qu;              
    (*e).value=x;          
    (*e).next=NULL;
    (*(*Q).rear).next=e;   
    (*Q).rear=e;           
}

elementtype FrontQ(qu *Q) { 
	if ((*Q).front==(*Q).rear) {
        printf("Red je prazan");
        exit(0);
     }
     else
         return((*(*(*Q).front).next).value); 
}

void DequeueQ(qu *Q) {             
	qu *e;                         
	if ((*Q).front==(*Q).rear) {
        printf("Red je prazan");
	  exit(0);
     }
	else {
	     e=(*Q).front;                 
         (*Q).front=(*(*Q).front).next; 
         free(e);                                  
     }
}

int IsEmptyQ(qu *Q){
     if ((*Q).front==(*Q).rear) 
         return(1);
     else
	   return(0);
}

//Iva Kis

Initial URL

                                

Initial Description

                                

Initial Title
red_pokazivac.h

Initial Tags

                                

Initial Language
C++