Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <set>
- #include <string>
- #include <sstream> // std::istringstream
- #include <algorithm> // std::find
- using namespace std;
- int main()
- {
- vector<string> carNumber;
- string input;
- string direction;
- string number;
- vector<string>::iterator it;
- while (true)
- {
- getline(cin, input);
- if (input == "END")
- break;
- istringstream istr(input);
- istr >> direction;
- istr >> number;
- if (direction == "IN,")
- carNumber.push_back(number);
- else if(carNumber.size() > 0)
- {
- it = find(carNumber.begin(), carNumber.end(), number);
- if (it != carNumber.end())
- carNumber.erase(it);
- }
- }
- if (carNumber.empty())
- cout << "Parking Lot is Empty" << endl;
- else
- for (string elm : carNumber)
- cout << elm << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment