/ Published in: C++
Implementacija reda pokazivaÄima
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#include <cstdlib> #include <iostream> using namespace std; struct tpacijent { int rbp; int x; int y; int z; }; struct t{ tpacijent vrij; t *sljedeci; }; struct q{ t *front, *rear; }; void initq(q *queue){ queue->front=(t*)malloc(sizeof(t)); queue->front->sljedeci=NULL; queue->rear=queue->front; }; bool isemptyq(q*queue){ if(queue->front==queue->rear) return true; else return false; }; void enqueueq(tpacijent x,q *queue){ t *pom; pom=new t; pom->vrij=x; pom->sljedeci=NULL; queue->rear->sljedeci=pom; queue->rear=pom; }; void dequeueq(q*queue){ t *pom; if(isemptyq(queue)) cout<<"Red je prazan"; else{ pom=queue->front; queue->front=queue->front->sljedeci; free(pom); } }; tpacijent frontq(q *queue){ if(isemptyq(queue)) cout<<"Red je prazan"; else return (queue->front->sljedeci->vrij); };
URL: /