Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <queue>
- #include <sstream>
- using namespace std;
- int main() {
- string line, name;
- getline(cin, line);
- istringstream ss(line);
- queue<string> names;
- while (ss >> name) {
- names.push(name);
- }
- int n;
- cin >> n;
- while (names.size() != 1) {
- for (size_t i = 1; i < n; i++) {
- names.push(names.front());
- names.pop();
- }
- cout << "Removed " << names.front() << endl;
- names.pop();
- }
- cout << "Last is " << names.front() << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement