Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <sstream>
- #include <vector>
- #include <queue>
- using namespace std;
- int main() {
- int n;
- string s;
- getline(cin, s);
- istringstream ss(s);
- ss >> n;
- vector<queue<string> > v(n);
- string linia, nom;
- for (int i = 0; i < n; ++i) {
- getline(cin, linia);
- istringstream lin(linia);
- while (lin >> nom) v[i].push(nom);
- }
- string activity;
- int cua;
- cout << "SORTIDES" << endl << "--------" << endl;
- while (cin >> activity) {
- if (activity == "SURT") {
- cin >> cua;
- cua--;
- if (cua >= 0 and cua < n) {
- if (not v[cua].empty()) {
- cout << v[cua].front() << endl;
- v[cua].pop();
- }
- }
- }
- else if (activity == "ENTRA") {
- cin >> nom >> cua;
- cua--;
- if (cua >= 0 and cua < n) {
- v[cua].push(nom);
- }
- }
- }
- cout << endl << "CONTINGUTS FINALS" << endl << "-----------------" << endl;
- for (int i = 0; i < n; ++i) {
- cout << "cua " << i+1 << ":";
- while (not v[i].empty()) {
- cout << " " << v[i].front();
- v[i].pop();
- }
- cout << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement