Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <sstream>
- #include <string>
- #include <list>
- #include <map>
- using namespace std;
- int main() {
- string resource;
- getline(cin, resource);
- list<pair<string, int>> resources;
- int quantity;
- while (resource != "stop") {
- cin >> quantity;
- bool isresource = false;
- for (auto& r : resources) {
- if (r.first == resource) {
- r.second += quantity;
- isresource = true;
- break;
- }
- }
- if (!isresource) {
- resources.push_back(make_pair(resource, quantity));
- }
- cin.ignore();
- getline(cin, resource);
- }
- for (auto &r : resources) {
- cout << r.first << " -> " << r.second << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement