Advertisement
Spocoman

6. Supermarket

Jan 10th, 2024
1,116
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <queue>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8.     string line;
  9.     getline(cin, line);
  10.  
  11.     queue<string> names;
  12.  
  13.     while (line != "End") {
  14.         if (line == "Paid") {
  15.             while (!names.empty()) {
  16.                 cout << names.front() << endl;
  17.                 names.pop();
  18.             }
  19.         }
  20.         else {
  21.             names.push(line);
  22.         }
  23.         getline(cin, line);
  24.     }
  25.  
  26.     cout << names.size() << " people remaining.\n";
  27.     return 0;
  28. }
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement