Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //5
- //Sofia beer 1.20 160
- //Varna chocolate 2.35 86
- //Sofia coffee 0.40 853
- //Varna apple 0.86 75.44
- //Plovdiv beer 1.10 88
- //
- //Plovdiv -> 96.80
- //Sofia -> 533.20
- //Varna -> 266.98
- #include <iostream>
- #include <string>
- #include <map>
- using namespace std;
- class Sales
- {
- public:
- Sales() = default;
- void add(string town, string product /*not used*/, double price, double quantity)
- {
- sales[town] += price * quantity;
- }
- void print() const
- {
- cout << fixed;
- cout.precision(2);
- for (const auto& item : sales)
- cout << item.first << " -> " << item.second << endl;
- }
- private:
- map<string, double> sales;
- };
- int main()
- {
- Sales s;
- string town, product;
- double price, quantity;
- int n;
- cin >> n;
- for (size_t i = 0; i < n; i++)
- {
- cin >> town >> product >> price >> quantity;
- s.add(town, product, price, quantity);
- }
- s.print();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement