#include <stdio.h>
#include <string.h>
int que[10001];
int que_size=0;

void Push(int num) {
    que[que_size]=num;
    que_size++;
}
int Empty() {
    if(que_size==0) {
        return 1;
    }
    return 0;
}
int Pop(void) {
    if(Empty()) return -1;
    que_size--;
    return que[0];
}
void Set() {
    for (int i=0; i<que_size; i++) {
        que[i]=que[i+1];
    }
}
int Front() {
    if(Empty()) return -1;
    return que[0];
}
int Back() {
    if(Empty()) return -1;
    return que[que_size-1];
}
int main() {
    int n;
    scanf("%d",&n);
    while(n--) {
        char command[10]={0};
        scanf("%s",command);
        if (!strcmp(command,"push")) {
            int x;
            scanf("%d",&x);
            Push(x);
        }
        else if (!strcmp(command,"pop")) {
            printf("%d\n",Pop());
            Set();
        }//Empty 잇으면 0
        else if (!strcmp(command,"empty")) {
            printf("%d\n",Empty());
        }
        else if (!strcmp(command,"front")) {
            printf("%d\n",Front());
        }
        else if (!strcmp(command,"back")) {
            printf("%d\n",Back());
        }
        else if (!strcmp(command,"size")) {
            printf("%d\n",que_size);
        }
    }
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: