0
I am working on a circular queue program where I want to implement a "queue break" function, where the user inserts a number and this number should be inserted in the queue spaces prior to f.com. But the logic that I implemented didn’t seem to work very well, I would like to ask for help with ideas or on what to do effectively in the code. I declared my line like this:
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;
}
So I declare the queue and start on main, the function I tried to create but it didn’t 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?
But the countryside
com
represents what ? and what is the difference betweenfim
andtotal
? Field names are not very clear.– Isac
com = start of queue end represents the end of queue and the total is only one variable to get the total number of elements in the queue, assisting in the display function.
– Kelvin Huggies
"this number should be inserted in row spaces prior to f.com" - from position
0
untilf.com
? You can show an example of before usingfurafila
?– Isac
For example I have the queue with indexes and numbers: I = start, F= Final 0 1 2 22 14 10 I F Stick queue with number 72 0 1 2 3 72 22 14 10 I F
– Kelvin Huggies