/ Published in: C++
Header pokazivaci
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#include <cstdlib> #include <iostream> using namespace std; struct _pacijent { int broj, cekaonica, ordinacija, prioritet; }; struct _t { _pacijent pacijent; _t *sljedeci; }; struct _red { _t *front, *rear; }; void InitQ(_red *red) { red->front=(_t*)malloc(sizeof(_t)); red->front->sljedeci=NULL; red->rear=red->front; cout<<"Red inicijaliziran!"<<endl; }; bool IsEmptyQ(_red *red) { if(red->front==red->rear) return true; else return false; }; void EnQueueQ(_pacijent pacijent,_red *red) { _t *temp; temp=new _t; temp->pacijent=pacijent; temp->sljedeci=NULL; red->rear->sljedeci=c; red->rear=temp; }; void DeQueueQ(_red *red) { _t *temp; if(IsEmptyQ(red)) cout<<"Red prazan!"<<endl; else { temp=red->front; red->front=red->front->sljedeci; free(temp); } }; _pacijent FrontQ(_red *red) { if(IsEmptyQ(red)) cout<<"Red prazan!"<<endl; else return (red->front->sljedeci->pacijent); }