Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <sstream>
- #include <deque>
- using namespace std;
- int main() {
- deque<string> d1, d2, d3;
- string name;
- cin >> name;
- while (name != "5") {
- if (name == "10") {
- d1.pop_front();
- }
- else if (name == "20") {
- d2.pop_front();
- }
- else if (name == "12") {
- d2.push_back(d1.front());
- d1.pop_front();
- }
- else if (name == "23") {
- d3.push_back(d2.front());
- d2.pop_front();
- }
- else if (name == "31") {
- d1.push_back(d3.back());
- d3.pop_back();
- }
- else if (name == "99") {
- cout << "1: ";
- if (d1.empty()) {
- cout << "<empty>";
- }
- for (auto it = d1.begin(); it != d1.end(); ++it) {
- cout << *it << ' ';
- }
- cout << endl << "2: ";
- if (d2.empty()) {
- cout << "<empty>";
- }
- for (auto it = d2.begin(); it != d2.end(); ++it) {
- cout << *it << ' ';
- }
- cout << endl << "3: ";
- if (d3.empty()) {
- cout << "<empty>";
- }
- for (auto it = d3.rbegin(); it != d3.rend(); ++it) {
- cout << *it << ' ';
- }
- cout << endl;
- }
- else {
- int n;
- cin >> n;
- n == 1 ? d1.push_back(name) : d2.push_back(name);
- }
- cin >> name;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement