#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define QUE_LENGTH 100
struct queue{
int head;
int tail;
char *array[QUE_LENGTH];
};
struct queue *create_queue(){
struct queue
* q
= malloc(sizeof(struct queue
)); q->head = 0;
q->tail = 0;
return q;
}
void enqueue(struct queue *q, char *s){
q->array[q->tail] = t;
if(q->tail == QUE_LENGTH)
q->tail = 0;
else
q->tail++;
}
void dequeue(struct queue *q, char *buffer){
strcpy(buffer
, q
->array
[q
->head
]); if(q->head == QUE_LENGTH)
q->head = 0;
else
q->head++;
}
int main(int argc, char *argv[]){
int n = 10;
char buffer[100];
struct queue *q = create_queue();
if(argc > 1){
++argv;
if(**argv == '-')
}
while(fgets(buffer
, 100, stdin
)){ enqueue(q, buffer);
}
while(n--){
dequeue(q, buffer);
}
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KI2luY2x1ZGUgPHN0cmluZy5oPgoKI2RlZmluZSBRVUVfTEVOR1RIIDEwMAoKc3RydWN0IHF1ZXVlewoJaW50IGhlYWQ7CglpbnQgdGFpbDsKCWNoYXIgKmFycmF5W1FVRV9MRU5HVEhdOwp9OwoKc3RydWN0IHF1ZXVlICpjcmVhdGVfcXVldWUoKXsKCXN0cnVjdCBxdWV1ZSogcSA9IG1hbGxvYyhzaXplb2Yoc3RydWN0IHF1ZXVlKSk7CglxLT5oZWFkID0gMDsKCXEtPnRhaWwgPSAwOwoJcmV0dXJuIHE7Cn0KCnZvaWQgZW5xdWV1ZShzdHJ1Y3QgcXVldWUgKnEsIGNoYXIgKnMpewoJY2hhciAqdCA9IG1hbGxvYygxMDApOwoJc3RyY3B5KHQsIHMpOwoJcS0+YXJyYXlbcS0+dGFpbF0gPSB0OwoJaWYocS0+dGFpbCA9PSBRVUVfTEVOR1RIKQoJCXEtPnRhaWwgPSAwOwoJZWxzZQoJCXEtPnRhaWwrKzsKfQoKdm9pZCBkZXF1ZXVlKHN0cnVjdCBxdWV1ZSAq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