I made a data structure algorithm. I put all my knowledge into it. I can not find the error. I leave the exercise statement below:
Make a program that creates two F1 and F2 queues, each one of size 10. Read 20 integers, and if the number read is even, insert it in the F1 and, if it is odd, in row F2. Then, if the number read is multiple of 3, remove an element from row F1, storing it in a auxiliary variable, and then write it in the video and insert it into the F2 queue. If the read number is multiple of 5, remove an element from row F2, by storing it in an auxiliary variable, and then write it in the video and insert it in the F1 queue. A number can be either multiple of 3 or 5, and in this case, post a message on the video and do nothing in the reading the next number. Stop reading when have already been read or when overflow or underflow in some queue.
int main()
{
int f=-1, r=-1, f1[10], f2[10], cont=0, val=0, aux=0, tam=9;
do{
cout << "Informe um valor: " << endl;
cin >> val;
cout << " " << endl;
if(val%2==0){
if(r==tam){
cout << "OVERFLOW!" << endl << endl;
return 0;
}else{
f1[++r]=val;
}
}else{
if(r==tam){
cout << "OVERFLOW!" << endl << endl;
return 0;
}else{
f2[++r]=val;
}
}
if(val%3==0){
if(r==f){
cout << "UNDERFLOW!" << endl << endl;
return 0;
}else{
aux=f1[f+1];
f++;
if(f==r){
f=r=-1;
cout << "Valor retirado: " << aux << endl << endl;
f2[++r]=aux;
}
}
}
if(val%5==0){
if(r==f){
cout << "UNDERFLOW!" << endl << endl;
return 0;
}else{
aux=f2[f+1];
f++;
if(f==r){
f=r=-1;
cout << "Valor retirado: " << aux << endl << endl;
f1[++r]=aux;
}
}
}
if(val%3==0 && val%5==0){
cout << "Numero mulitplo de 3 e 5!" << endl << endl;
}
cont++;
}while(cont < 20);
return 0;
}