Return to Snippet

Revision: 53822
at December 2, 2011 22:40 by vimandic


Initial Code
struct qu {
	elementtype value;
	struct qu *next;
};

struct que {
	struct qu *front,*rear;
};

typedef struct que queue;
typedef struct qu *element;

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

void EnqueueQ( elementtype x,queue *Q) {
	element e;
	e=(struct qu *)malloc(sizeof(struct qu));
    (*e).value=x;
    (*e).next=NULL;
    (*(*Q).rear).next=e;
    (*Q).rear=e;
}

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

void InitQ(queue *Q) {
	element e;
	e=(struct qu *)malloc(sizeof(struct qu));
    (*Q).front=e;
    (*Q).rear=e;
    (*e).next=NULL;
}

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

Initial URL

                                

Initial Description
Implementacija reda pomoću pokazivača

Initial Title
Impl reda pomocu pokazivaca

Initial Tags

                                

Initial Language
C++