/ Published in: C++
Atp red implementacija pomoću polja.
Expand |
Embed | Plain Text
#include<iostream> using namespace std; struct red{ int x,y,pr; }; struct tred{ int prednji,zadnji; red polje[1000]; }; int n=999; red FrontQ(tred *Q){ if(!IsEmptyQ(Q)) return Q->polje[Q->prednji]; } void EnQueueQ(red x,tred *Q){ Q->zadnji=AddOne(Q->zadnji); Q->polje[Q->zadnji]=x; } void DeQueueQ(tred *Q){ if(!IsEmptyQ(Q)) Q->prednji=AddOne(Q->prednji); } void InitQ(tred *Q){ Q->prednji=0; Q->zadnji=n; } bool IsEmptyQ(tred *Q){ if(AddOne(Q->zadnji)==Q->prednji) return true; else return false; } int AddOne(int n) { return((n+1)%1000); }
You need to login to post a comment.
