#include <stdio.h>
#include <stdlib.h>
#define N 10
int suc(int p){
int temp;
if (p==N)
temp=1;
else
temp=p+1;
return(temp);
}
void inserir(char F[], int i, int *f, int *over, int *c, char ch){
*over= 0;
if(suc(*f)==i){
*over=1;
}
else{
*f=suc(*f);
F[*f]=ch;
*c = *c + 1;
}
}
char remover(char F[], int *i, int f, int *c){
char temp;
if(*i==f)
else
{ *i=suc(*i);
temp=F[*i];
*c = *c + 1;
}
return(temp);
}
void exibirSomenteFila(char F[], int i, int f){
int x;
if (i == f)
else
{
x=i;
while (x != f){
x = suc(x);
}
}
}
int main(){
char F[N+1], ch;
int i,f, minutos, contador, ov, r, k ;
minutos=0;
i=1;
f=1;
contador=0;
ov=0;
while(contador<40){
minutos++;
if (minutos % 2==0){
inserir(F, i, &f, &ov, &contador, 'a');
if (ov==1){
printf("A area sera esvaziada"); exibirSomenteFila(F,i,f);
while (i != f){
ch=remover(F, &i, f, &contador);
}
inserir(F, i, &f, &ov, &contador, 'a');
exibirSomenteFila(F,i,f);
}
}
if (minutos%3==0){
k=1;
while (k<=r){
ch=remover(F, &i, f, &contador);
k++;
}
}
if (minutos%8==0)
exibirSomenteFila(F,i,f);
}
exibirSomenteFila(F,i,f);
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KI2RlZmluZSBOIDEwCiAKaW50IHN1YyhpbnQgcCl7CiAKICAgIGludCB0ZW1wOwogICAgaWYgKHA9PU4pCiAgICAgICAgdGVtcD0xOwogICAgZWxzZQogICAgICAgIHRlbXA9cCsxOwogICAgcmV0dXJuKHRlbXApOwp9CiAKdm9pZCBpbnNlcmlyKGNoYXIgRltdLCBpbnQgaSwgaW50ICpmLCBpbnQgKm92ZXIsIGludCAqYywgY2hhciBjaCl7CiAKICAgICpvdmVyPSAwOwogICAgaWYoc3VjKCpmKT09aSl7CiAgICAgICAgcHJpbnRmKCJPdmVyZmxvdyBuYSBmaWxhXG4iKTsKICAgICAgICAqb3Zlcj0xOwogICAgfQogICAgZWxzZXsKICAgICAgICAqZj1zdWMoKmYpOwogICAgICAgIEZbKmZdPWNoOwogICAgICAgICpjID0gKmMgKyAxOwogICAgfQogCn0KIApjaGFyIHJlbW92ZXIoY2hhciBGW10sIGludCAqaSwgaW50IGYsIGludCAqYyl7CiAKICAgIGNoYXIgdGVtcDsKICAgIGlmKCppPT1mKQogICAgICAgIHByaW50ZigiVW5kZXJmbG93IG5hIGZpbGEiKTsKICAgIGVsc2UKICAgIHsgICAqaT1zdWMoKmkpOwogICAgICAgIHRlbXA9RlsqaV07CiAgICAgICAgKmMgPSAqYyArIDE7CiAgICB9CiAKICAgIHJldHVybih0ZW1wKTsKfQogCnZvaWQgZXhpYmlyU29tZW50ZUZpbGEoY2hhciBGW10sIGludCBpLCBpbnQgZil7CiAKICAgaW50IHg7CiAgIGlmIChpID09IGYpCiAgICAgcHJpbnRmICgiXG5GaWxhIHZhemlhIik7CiAgIGVsc2UKICAgeyAKICAgCSAgIHg9aTsKICAgICAgIHdoaWxlICh4ICE9IGYpeyAKICAgICAgIAl4ID0gc3VjKHgpOwogICAgICAgIHByaW50ZigiICVjICIsRlt4XSk7CiAgICAgICB9CiAgIH0KICAgcHJpbnRmICgiXG4iKTsKfQogCmludCBtYWluKCl7CiAKCWNoYXIgRltOKzFdLCBjaDsKCWludCBpLGYsIG1pbnV0b3MsIGNvbnRhZG9yLCBvdiwgciwgayA7CiAKCW1pbnV0b3M9MDsKCWk9MTsKCWY9MTsKCWNvbnRhZG9yPTA7Cglvdj0wOwogCgl3aGlsZShjb250YWRvcjw0MCl7CiAKCSAgICBtaW51dG9zKys7CgkgICAgaWYgKG1pbnV0b3MgJSAyPT0wKXsKCSAgICAgICAgaW5zZXJpcihGLCBpLCAmZiwgJm92LCAmY29udGFkb3IsICdhJyk7CgkgICAgICAgIGlmIChvdj09MSl7CgkgICAgICAgICAgICBwcmludGYoIkEgYXJlYSBzZXJhIGVzdmF6aWFkYSIpOwoJICAgICAgICAgICAgZXhpYmlyU29tZW50ZUZpbGEoRixpLGYpOwoJICAgICAgICAgICAgd2hpbGUgKGkgIT0gZil7CgkgICAgICAgICAgICAgICAgY2g9cmVtb3ZlcihGLCAmaSwgZiwgJmNvbnRhZG9yKTsKCSAgICAgICAgICAgICAgICBwcmludGYoIiVkIiwgY2gpOwoJICAgICAgICAgICAgfQoJICAgICAgICAgICAgaW5zZXJpcihGLCBpLCAmZiwgJm92LCAmY29udGFkb3IsICdhJyk7CgkgICAgICAgICAgICBleGliaXJTb21lbnRlRmlsYShGLGksZik7CgkgICAgICAgIH0KCSAgICB9CiAKCSAgICBpZiAobWludXRvcyUzPT0wKXsKCSAgICAgICAgcj1yYW5kKCkgJSAzOwoJICAgICAgICBrPTE7CgkgICAgICAgIHdoaWxlIChrPD1yKXsKCSAgICAgICAgICAgIGNoPXJlbW92ZXIoRiwgJmksIGYsICZjb250YWRvcik7CgkgICAgICAgICAgICBwcmludGYoIiVjIiwgY2gpOwoJICAgICAgICAgICAgaysrOwoJICAgICAgICB9CgkgICAgfQogCgkgICAgaWYgKG1pbnV0b3MlOD09MCkKCSAgICAgICAgZXhpYmlyU29tZW50ZUZpbGEoRixpLGYpOwoJfQogCglleGliaXJTb21lbnRlRmlsYShGLGksZik7CgkKCXJldHVybiAwOwp9