https://www.acmicpc.net/problem/10845
#include<stdio.h>
#include<string.h>
struct Queue{
int queue[10001];
int first;
int last;
}t;
void push(int num) {
t.queue[t.last] = num;
t.last++;
}
void pop() {
if(t.last-t.first == 0) printf("-1\n");
else {
int ans = t.queue[t.first];
t.queue[t.first] = 0;
t.first++;
printf("%d\n",ans);
}
}
void size() {
printf("%d\n",t.last-t.first);
}
void empty() {
if(t.last-t.first == 0) printf("1\n");
else printf("0\n");
}
static void front() {
if(t.last-t.first == 0) printf("-1\n");
else printf("%d\n",t.queue[t.first]);
}
static void back() {
if(t.last-t.first == 0) printf("-1\n");
else printf("%d\n",t.queue[t.last - 1]);
}
int main() {
t.first=0;
t.last=0;
int n;
scanf("%d",&n);
for(int i=0;i<n;i++){
char st[10];
scanf("%s",&st);
if (strcmp(st, "push")==0) {
int num;
scanf("%d", &num);
push(num);
}
else if(strcmp(st, "pop")==0) {
pop();
}
else if(strcmp(st, "size")==0) {
size();
}
else if(strcmp(st, "empty")==0) {
empty();
}
else if(strcmp(st, "front")==0) {
front();
}
else if(strcmp(st, "back")==0) {
back();
}
}
}