求助啊!!全都WA了!!!
查看原帖
求助啊!!全都WA了!!!
1412615
H_first楼主2024/8/8 11:51
#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;
int que[10010];
int hh=0,tt=-1;
void push(int x)
{
    que[++tt]=x;
}
void pop()
{
	if(hh>tt) puts("ERR_CANNOT_POP\n");
    else hh++;
}
void query()
{
   if(hh>tt) puts("ERR_CANNOT_QUERY\n");
    else printf("%d\n",que[hh]);
}
int size()
{
    return tt-hh+1;
}
int main()
{
    int n;
    scanf("%d",&n);
    while(n--)
    {
        int s;
        scanf("%d",&s);
        if(s==1)
        {
            int x;
            scanf("%d",&x);
            push(x);
        }
        else if(s==2) pop();
        else if(s==3) query();
        else printf("%d\n",size());
    }
    return 0;
}
2024/8/8 11:51
加载中...