改了好几次发现格式错误的地方 呜呜呜

#include <iostream>
#include <cstdio>
#include <stack>

using namespace std;

int main() {
  int n,m;
  char c;
  stack<int> mystack;
  while (scanf("%d", &n) != EOF) {
    for (int i = 0; i < n; ++i) {
      scanf(" %c", &c); //注意此处输入格式
      if (c == 'P') {
        scanf("%d", &m);
        mystack.push(m);
      } else if (c == 'O') {
          if (!mystack.empty()) {
            mystack.pop();
          }
      } else if (c == 'A') {
          if (mystack.empty()) {
            printf("E\n");
          } else {
            printf("%d\n", mystack.top());
          }
      }
    }
      printf("\n");
      while (!mystack.empty()) {
          mystack.pop();
      }
  }
  return 0;
}