red_polje.h





0
Date Submitted Sun. Nov. 21st, 2010 2:45 PM
Revision 1 of 1
Beginner martina_granic
Tags polje | red
Comments 0 comments
Implementacija pomocu reda


struct zapis{
       string prez_ime;
       int god, transakcija;
       double stanje_racuna;
       };
typedef zapis klijent;

struct element{
       klijent K[1000];
       int front,rear;
       };
typedef struct element red;

int AddOne(int n){
        return ((n+1)%1000);
};

klijent FrontQ(red *Q){
        if(AddOne(Q->rear) == Q->front)
        cout << "Red je prazan" << endl;
        exit(1);
        else {
             return Q->K[Q->front];
             }       
};

void EnQueueQ(klijent x,red *Q){
     if (AddOne(AddOne(Q->rear)) == Q->front){
      cout << "Red je pun" << endl;
      return;
      }
     else {
          Q->rear=AddOne(Q->rear);
          Q->K[Q->rear] = x;
         
     }   
};

void DeQueueQ(red *Q){
     if (AddOne(Q->rear) == Q->front)
     cout << "Red je prazan" << endl;
     return;     
     else {
        Q->front = AddOne(Q->front);
     }                               
};

bool IsEmptyQ(red *Q){
    if(AddOne(Q->rear) == Q->front)
    return true;
    else
    return false;
};

red *InitQ(red *Q){
    Q = new red;
    Q->rear = 9999;
    Q->front = 0;
    return Q;   
};

 

Martina Granic

Comments

There are currently no comments for this snippet.

Voting

Votes Up


Votes Down