Return to Snippet

Revision: 36280
at November 20, 2010 04:03 by ivvuljak


Initial Code
using namespace std;

struct tklijent{     
       char ime[15];
       char prezime[20];
       char transakcija[20];
       int god_rodenja;
       int stanje_rac;       
};
typedef tklijent elementtype; 
struct qu {                   
   elementtype value;
   struct qu *next;
};

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

typedef struct que queue;     
typedef struct qu *element; 

bool IsEmptyQ(queue *Q){
	if (Q->rear == Q->front) return true; 
	else return false;
}

elementtype FrontQ(queue *Q){ 
	if (IsEmptyQ(Q)){
		cout << "Red je prazan!" << endl;
		exit(1);
	}
	return Q->front->next->value; 
}

void EnqueueQ(elementtype x , queue *Q){ 
	element novi , prethodni;      
	novi = new qu;                  
	novi->value = x;                
	prethodni = Q->rear;           
	prethodni->next = novi;         
	Q->rear = novi;              
}

void DequeueQ(queue *Q){ 
	if (IsEmptyQ(Q)){
		cout << "Red je prazan!" << endl;
		exit(1);
	}
	element brisi; 
	brisi = Q->front;       
	Q->front = brisi->next;  
	delete(brisi);          
}

void InitQ(queue *Q){
	element e;                
	e = new qu;                
	e->next = NULL;           
	Q->front = Q->rear = e;   
}

Initial URL

                                

Initial Description

                                

Initial Title
red_pokazivac.h

Initial Tags

                                

Initial Language
C++