大佬求救只过了一个
查看原帖
大佬求救只过了一个
1604276
handless楼主2024/12/27 15:30
#include <iostream>
#include <string>

using namespace std;
typedef unsigned long long ull;

const int N = 1e6+10;
int id;
ull st[N];

void push(int x)
{
  st[++id]=x;
}

void query()
{
  if(id==0)
  {
    cout << "Anguei!" << endl;
  }
  else
  {
    cout << st[id] << endl;
  }
}

int size()
{
  return id;
}

void pop()
{
  if(id==0)
  {
    cout << "Empty" << endl;
  }
  else
  {
    id--;
  }
}

int main()
{
  ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
  int t;
  cin >> t;
  while(t--)
  {
    id = 0;
    int n;
    cin >> n;
    for(int i=0;i<n;i++)
    {
      string op;
      cin >> op;
      if(op=="push")
      {
        ull x;
        cin >> x;
        push(x);
      }
      else if(op=="query")
      {
        query();
      }
      else if(op=="size")
      {
        cout << size() << endl;
      }
      else 
      {
        pop();
      }
    }
  }
  return 0;
}
2024/12/27 15:30
加载中...