/ Published in: C++
zadatak 3
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#include<iostream> using namespace std; struct podaci{ int a,b,c,d; }; struct red{ podaci brojevi; red *sljedeci; }; struct reda{ red *front, *rear; }; reda *InitQ(reda *Q){ red *novi=new red; Q=new reda; Q->front=novi; Q->rear=novi; novi->sljedeci=NULL; return Q; } podaci FrontQ(reda *Q){ return Q->front->sljedeci->brojevi; } void EnQueueQ(podaci x, reda *Q){ red *novi=new red; novi->brojevi=x; Q->rear->sljedeci=novi; novi->sljedeci=NULL; Q->rear=novi; } void DeQueueQ(reda *Q){ if(Q->front != Q->rear){ red *brisi=Q->front; Q->front=brisi->sljedeci; delete brisi; } else cout<<"red je prazan"<<endl; } bool IsEmptyQ(reda *Q){ if(Q->front==Q->rear) return 1; else return 0; }