AtCoder 第402场初级竞赛 A~E题解
A CBC
【题目链接】
原题链接:A - CBC
【考点】
枚举
【题目大意】
找出所有的大写字母
【解析】
遍历字符串,判断是否为大写字母,如果是则输出。
【难度】
GESP二级
【代码参考】
#include <bits/stdc++.h>
using namespace std;int main() {string s;cin >> s;for(int i = 0; i < s.size(); i++){if(s[i] >= 'A' && s[i] <= 'Z') cout << s[i];}return 0;
}
B Restaurant Queue
【题目链接】
原题链接:B - Restaurant Queue
【考点】
队列,模拟
【题目大意】
两种操作,操作1是有一位顾客拿着菜单号排在队尾,操作2则引导队头的顾客进入餐厅。
【解析】
题目在模拟数据结构队列的操作,直接使用STL的queue模拟即可。
【难度】
GESP六级
【代码参考】
#include <bits/stdc++.h>
using namespace std;int main() {int n, t, k;queue<int> q;cin >> n;for(int i = 1; i <= n; i++){cin >> t;if(t == 1){cin >> k;q.push(k);}else{k = q.front();cout << k << endl;q.pop();}}return 0;
}