kolioi

03. Products and Cities C++ Exam

Jan 22nd, 2019
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <map>
  4.  
  5. int main()
  6. {
  7.     using namespace std;
  8.  
  9.     size_t n;
  10.     cin >> n;
  11.  
  12.     map<string, double> data;
  13.     for (;data.size() < n;) //while(data.size() < n)
  14.     {
  15.         string city;
  16.         double price, quantity;
  17.         cin >> city >> price >> quantity;
  18.         data[city] += price * quantity;
  19.     }
  20.  
  21.     for (const auto& c : data)
  22.         cout << c.first << ' ' << c.second << endl;
  23.  
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment