#include <stdio.h>
#define SIZE 5
int queue[SIZE];
int head,tail;
void enqueue(int value);
int dequeue(void);
int main(void) {
head=tail=0;
int data,i;
enqueue(1);
enqueue(2);
dequeue();
enqueue(3);
dequeue();
enqueue(4);
enqueue(5);
dequeue();
enqueue(6);
for (i=0;i<SIZE;i++){
printf("queue[%d]=%d\n",i
,queue
[i
]); }
return 0;
}
void enqueue(int value){
if(head==(tail+1)%SIZE){
}else{
queue[tail++]=value;
}
tail=tail%SIZE;
}
int dequeue(void){
int value;
if(head==tail){
}else{
//queue[head]=0;
queue[head++]=0;
}
head=head%SIZE;
return 0;//value;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgojZGVmaW5lIFNJWkUgNQppbnQgcXVldWVbU0laRV07CmludCBoZWFkLHRhaWw7Cgp2b2lkIGVucXVldWUoaW50IHZhbHVlKTsKaW50IGRlcXVldWUodm9pZCk7CgppbnQgbWFpbih2b2lkKSB7CgloZWFkPXRhaWw9MDsKCWludCBkYXRhLGk7CgkKCWVucXVldWUoMSk7CgllbnF1ZXVlKDIpOwoJZGVxdWV1ZSgpOwoJZW5xdWV1ZSgzKTsKCWRlcXVldWUoKTsKCWVucXVldWUoNCk7CgllbnF1ZXVlKDUpOwoJZGVxdWV1ZSgpOwoJZW5xdWV1ZSg2KTsKCQoJZm9yIChpPTA7aTxTSVpFO2krKyl7CgkJcHJpbnRmKCJxdWV1ZVslZF09JWRcbiIsaSxxdWV1ZVtpXSk7Cgl9CglyZXR1cm4gMDsKfQoKdm9pZCBlbnF1ZXVlKGludCB2YWx1ZSl7CglpZihoZWFkPT0odGFpbCsxKSVTSVpFKXsKCQlwcmludGYoIuOCreODpeODvOOBr+a6gOadr+OBp+WFpeOCiuOBvuOBm+OCk+OBp+OBl+OBn1xuIik7Cgl9ZWxzZXsKCQlxdWV1ZVt0YWlsKytdPXZhbHVlOwoJfQoJdGFpbD10YWlsJVNJWkU7Cn0KCmludCBkZXF1ZXVlKHZvaWQpewoJaW50IHZhbHVlOwoJaWYoaGVhZD09dGFpbCl7CgkJcHJpbnRmKCLjgq3jg6Xjg7zjga/nqbrjgaflj5bjgorlh7rjgZvjgb7jgZvjgpPjgafjgZfjgZ9cbiIpOwoJfWVsc2V7CgkJLy9xdWV1ZVtoZWFkXT0wOwoJCXF1ZXVlW2hlYWQrK109MDsKCX0KCWhlYWQ9aGVhZCVTSVpFOwoJcmV0dXJuIDA7Ly92YWx1ZTsKfQ==