Advertisement
Spocoman

05. Parking Lot

Jan 21st, 2024
989
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <set>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8.     string line, command, numberPlate;
  9.     getline(cin, line);
  10.  
  11.     set<string> numberPlates;
  12.  
  13.     while (line != "END") {
  14.         command = line.substr(0, line.find(','));
  15.         numberPlate = line.substr(line.find(',') + 2);
  16.  
  17.         numberPlates.insert(numberPlate);
  18.  
  19.         if (command == "OUT") {
  20.             numberPlates.erase(numberPlate);
  21.         }
  22.      
  23.         getline(cin, line);
  24.     }
  25.  
  26.     if (numberPlates.empty()) {
  27.         cout << "Parking Lot is Empty\n";
  28.     }
  29.     for (auto& n : numberPlates) {
  30.         cout << n << endl;
  31.     }
  32.  
  33.     return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement