[SmartOJ1295]银行取款

来源:互联网 发布:淘宝一加3邀请码靠谱吗 编辑:程序博客网 时间:2024/04/29 20:52

题目在此

使用STL队列,AC.

#include <cstdio>#include <queue>#include <iostream>using namespace std;queue<int> q;int main(){    char z;    int x;    while(cin>>z){    if(z=='I'){    scanf("%d",&x);    q.push(x);    }    if(z=='O'){    if(q.empty()==1)printf("None\n");        else {printf("%d\n",q.front());              q.pop();}    }    }    return 0;}