#include #include #include #include using namespace std; struct account { int number; int bank; bool operator< (const account &a1) const { return (this->number < a1.number); } bool operator= (const account &a1) const { if((number == a1.number) && (bank == a1.bank)) return true; return false; } }; int num_accounts=666; string operation("666"); char a; float par_money; account tmp,tmp2; int main() { while (true) { cin >> num_accounts; map accounts; if(num_accounts==0) { cout <<"goodbye"<> tmp.number >> a >> tmp.bank >> bal; accounts[tmp]=bal; // cout << "NEW" << tmp.number << " " << tmp.bank << " " << bal << endl; } operation="666"; while (operation != "end") { cin >> operation; /* map::iterator it; for (it = accounts.begin(); it != accounts.end(); it++) cout << "ucty: " << (it->first).number << " " << (it->first).bank << " " << (it->second) << endl; */ if(operation == "create") { cin >> tmp.number >> a >> tmp.bank; if(accounts.find(tmp) != accounts.end()) { cout << "create: already exists" << endl; } else { accounts[tmp]=0; cout << "create: ok"<> tmp.number >> a >> tmp.bank >> par_money; if(accounts.find(tmp) == accounts.end()) { cout << "deposit "; printf("%.2f",par_money); cout << ": no such account" <::iterator it; it=accounts.find(tmp); it->second+=par_money; cout << "deposit "; printf("%.2f",par_money); cout <<": ok" << endl; } } if(operation == "withdraw") { cin >> tmp.number >> a >> tmp.bank >> par_money; if(accounts.find(tmp) == accounts.end()) { cout << "withdraw "; printf("%.2f",par_money); cout << ": no such account" <second+0.0001 <= par_money) { // cout << "odebirame: " << par_money << " mame: " << accounts.find(tmp)->second << endl; cout << "withdraw "; printf("%.2f",par_money); cout << ": insufficient funds" << endl; } else { accounts.find(tmp)->second -= par_money; cout << "withdraw "; printf("%.2f",par_money); cout <<": ok" << endl; } } if(operation == "transfer") { cin >> tmp.number >> a >> tmp.bank >> tmp2.number >> a >> tmp2.bank >> par_money; if(accounts.find(tmp) == accounts.end()) { cout << "transfer "; printf("%.2f",par_money); cout << ": no such account" <second+0.0001 <= par_money) { cout << "transfer "; printf("%.2f",par_money); cout << ": insufficient funds" << endl; } else { accounts.find(tmp)->second -= par_money; accounts.find(tmp2)->second += par_money; cout << "transfer "; printf("%.2f",par_money); cout <<": "; if(tmp.bank == tmp2.bank) cout << "ok" << endl; else cout << "interbank" << endl; } } if (operation == "end") { cout <<"end" << endl << endl; } } } /* for (int i=0;i