/ Published in: C++
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#include <iostream> #include <cstring> using namespace std; struct zapis { string preime; int god,transakcija; double stanje_racuna; }; typedef zapis klijent; struct que { klijent K; que *next; }; struct queue { que *celo,*zacelje; }; typedef struct queue red; klijent FrontQ(red *Q) { if (Q->celo!=Q->zacelje) return(Q->celo->next->K); else { cout << "Red je prazan!" << endl; exit(1); } }; void EnQueueQ(klijent K,red *Q) { que *novi=new que; novi->K=K; novi->next=NULL; Q->zacelje->next=novi; Q->zacelje=novi; }; void DeQueueQ(red *Q) { if (Q->celo!=Q->zacelje) { que *pom=Q->celo; Q->celo=Q->celo->next; delete pom; } else { cout << "Red je prazan!" << endl; return; } }; queue *InitQ(red *Q) { Q=new red; que *novi=new que; Q->celo=novi; Q->zacelje=novi; novi->next=NULL; return Q; }; bool IsEmptyQ(red *Q) { if (Q->celo==Q->zacelje) return true; else return false; };