#include #include #include using namespace std; bool exists(map &m, string &a) { map::iterator it = m.find(a); return it != m.end(); } int readmoney() { int i,f; char c; cin >> i >> c >> f; // cout << i << " " << f << endl; return i*100+f; } string printmoney(int money) { stringstream s; int i = money / 100; int f = money % 100; s << i << "."; if (f<10) s << "0"; s << f; return s.str(); } int main() { string line; while (cin) { map accounts; int acnt; cin >> acnt; if (acnt==0) { cout << "goodbye" << endl; return 0; } for (int i=0; i> name; int balance = readmoney(); accounts[name] = balance; } while (true) { string cmd; cin >> cmd; if (cmd=="end") { cout << "end" << endl << endl; break; } string acc; cin >> acc; if (cmd == "create") { cout << "create: "; if (!exists(accounts,acc)) { accounts[acc] = 0; cout << "ok"; } else { cout << "already exists"; } } if (cmd == "deposit") { int money = readmoney(); cout << "deposit " << printmoney(money) << ": "; if (!exists(accounts, acc)) { cout << "no such account"; } else { accounts[acc] = accounts[acc] + money; cout << "ok"; } } if (cmd == "withdraw") { int money = readmoney(); cout << "withdraw " << printmoney(money) << ": "; if (!exists(accounts, acc)) { cout << "no such account"; } else { if (accounts[acc] >= money) { accounts[acc] = accounts[acc] - money; cout << "ok"; } else { cout << "insufficient funds"; } } } if (cmd == "transfer") { string acc2; cin >> acc2; int money = readmoney(); cout << "transfer " << printmoney(money) << ": "; if (!exists(accounts, acc) || !exists(accounts, acc2)) { cout << "no such account"; } else { if (acc == acc2) { cout << "same account"; } else { if (accounts[acc] >= money) { accounts[acc] = accounts[acc] - money; accounts[acc2] = accounts[acc2] + money; if (acc[acc.size()-1] == acc2[acc2.size()-1]) { cout << "ok"; } else { cout << "interbank"; } } else { cout << "insufficient funds"; } } } } cout << endl; } } return 0; }