Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <map>
- #include <vector>
- #include <algorithm>
- using namespace std;
- bool is_find(vector<string>& v, string el) {
- return find(v.begin(), v.end(), el) != v.end();
- }
- int main() {
- map<string, double> account;
- vector<string> currencies;
- string CURRENCY_TICKER, currency, sum;
- cin >> CURRENCY_TICKER;
- while (CURRENCY_TICKER != "END") {
- cin >> sum;
- account[CURRENCY_TICKER] += stod(sum);
- if (!is_find(currencies, CURRENCY_TICKER)) {
- currencies.push_back(CURRENCY_TICKER);
- }
- cin >> CURRENCY_TICKER;
- }
- cin >> CURRENCY_TICKER;
- while (CURRENCY_TICKER != "END") {
- if (CURRENCY_TICKER == "+" || CURRENCY_TICKER == "-") {
- cin >> currency >> sum;
- account[currency] += (CURRENCY_TICKER == "+" ? stod(sum) : -stod(sum));
- }
- else if (CURRENCY_TICKER == "X") {
- cin >> currency >> sum;
- double s = stod(sum);
- account[currency] -= s;
- cin >> currency >> sum;
- s *= stod(sum);
- account[currency] += s;
- }
- else {
- for (auto& c : currencies) {
- printf("%s: %.2f\n", c.c_str(), account[c]);
- }
- }
- cin >> CURRENCY_TICKER;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement