Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<string>
- #include <map>
- #include <iterator>
- #include <utility>
- using namespace std;
- int main()
- {
- int numCars;
- cin >> numCars;
- map<string, pair<string,int>> mymap = {};
- string made = "", model = "";
- int year = 0;
- for (int i = 0; i < numCars; i++)
- {
- cin >> made;
- cin >> model;
- cin >> year;
- mymap.insert(make_pair(made,make_pair(model,year)));
- }
- string options;
- cin >> options;
- if (options == "1")
- {
- cin >> made;
- for(auto it = mymap.cbegin(); it != mymap.cend(); ++it)
- {
- if (made == it->first)
- {
- cout << it->first << " " << it->second.first<< " " << it->second.second << endl;
- }
- }
- }
- if (options == "2")
- {
- for(auto it = mymap.cbegin(); it != mymap.cend(); ++it)
- {
- cout << it->first << " " << it->second.first<< " " << it->second.second << endl;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement