Return to Snippet

Revision: 36334
at November 20, 2010 21:35 by sejstefic


Initial Code
typedef int element;

struct qu {
       elementtype elements[10000];
       int front,rear;
       };

typedef struct qu queue;

int AddOne(int n) {
    return((n+1)%10000);
    }
    
int FrontQ(queue *Q){
    if (AddOne(*Q.rear)==(*Q.front)){
                                         cout<<"Red je prazan!"<<endl;
                                         }
    else 
         return (*Q.elements[*Q.front])
    }
    
void EnQueueQ(int x, queue*Q){
     if(AddOne(AddOne(*Q.rear)))==(*Q.front){
                                                 cout<<"Red je pun!"<<endl;
                                                 }
     else {
          *Q.rear=AddOne(*Q.rear);
          *Q.elements[*Q.rear]=x;
          }
     }

void DeQueueQ(queue *Q){
     if(AddOne(*Q.rear)==*Q.front)){
                                    cout<<"Red je prazan!"<<endl;
                                    }
     else *Q.front=AddOne(*Q.front);
     }
     
void InitQ(queue *Q){
     *Q.front=0;
     *Q.rear=10000-1;
     }
     
int IsEmpty (queue Q){
    if (AddOne(Q.rear)==Q.front) return 1;
    else return 0;
    }

Initial URL

                                

Initial Description

                                

Initial Title
implementacija reda pomocu cirkularnog polja sejstefic

Initial Tags

                                

Initial Language
C++