Insert at the beginning of a circular row

0

I'm working on a circular queue program where I want to implement a "stick queue" function where the user enters a number and this number should be entered in the queue spaces prior to f.com. But the logic I implemented did not seem to work very well, I would like to ask for help with ideas or what to do effectively in the code. I declare my queue assm:

struct circular
{   int com;
    int fim;
    int total;
    int memo[MAX];
}; 

typedef struct circular circular;
int main ()
{
    struct circular F;
    F.com = 0;
    F.total = 0;
    F.fim = -1;

}

In this way I declare the queue and initialize it in main, the function I tried to create however did not work was this:

void furafila(struct circular *F, int x)
{  int aux,aux2;
    aux = F->com;
    F->fim++;
    if(F->fim == MAX)
   {
      F->fim = 0;
   }
    aux2=F->fim;
    F->memo[F->fim] = x;
    F->com = aux2;
    F->fim = aux-1;
    F->total++;

}

Any suggestions?

    
asked by anonymous 14.06.2018 / 23:21

0 answers