#include #include #include #include #include using namespace std; int ddd(double f) { int i = (int)f; int p; for (p = 0; i > 0; p++) { i /= 10; } return p; } void aaa(double fl) { double f = fl; f *= 100; int i = (int)f; if (i%100 == 0) cout << ".0"; if (i%10 == 0) cout << "0"; } class Acc { private: int num; double val; public: Acc(int n, double v) { num = n; val = v; } bool vyber(double v) { if ((val-v) >= 0.0) { val-=v; return true; } else return false; } bool vloz(double v) { val += v; return true; } }; class Pole { private: map u; public: Pole() { } ~Pole() { //u.erase(); } void zaloz(int a, double v) { pair::iterator,bool> p; p = u.insert(make_pair(a, new Acc(a,v))); } void pridej(int a) { pair::iterator,bool> p; p = u.insert(make_pair(a, new Acc(a,0))); if (p.second) { cout << "create: ok\n"; } else { cout << "create: already exists\n"; } } void vloz(int a, double v) { map::iterator i = u.find(a); if (i != u.end()) { (*i).second->vloz(v); cout << "deposit " << setprecision(ddd(v)+2) << v ;aaa(v); cout << ": ok\n"; } else { cout << "deposit " << setprecision(ddd(v)+2) << v ;aaa(v); cout << ": no such account\n"; } } void vyber(int a, double v) { map::iterator i = u.find(a); if (i != u.end()) { if ((*i).second->vyber(v)) { cout << "withdraw " << setprecision(ddd(v)+2) << v ;aaa(v); cout << ": ok\n"; } else { cout << "withdraw " << setprecision(ddd(v)+2) << v ;aaa(v); cout << ": insufficient funds\n"; } } else { cout << "withdraw " << setprecision(ddd(v)+2) << v ;aaa(v); cout << ": no such account\n"; } } void trans(int a, double v, int b) { map::iterator i = u.find(a); map::iterator j = u.find(b); if (i == j) { cout << "transfer " << setprecision(ddd(v)+2) << v ;aaa(v); cout << ": same account\n"; } else if (i != u.end() && j != u.end()) { if ((*i).second->vyber(v)) { (*j).second->vloz(v); if (a%10 == b%10) { cout << "transfer " << setprecision(ddd(v)+2) << v ;aaa(v); cout << ": ok\n"; } else { cout << "transfer " << setprecision(ddd(v)+2) << v ;aaa(v); cout << ": interbank\n"; } } else { cout << "transfer " << setprecision(ddd(v)+2) << v ;aaa(v); cout << ": insufficient funds\n"; } } else { cout << "transfer " << setprecision(ddd(v)+2) << v ;aaa(v); cout << ": no such account\n"; } } }; int main(void) { Pole u; int p; cin >> p; // cout << p << endl; while (p != 0) { u.erase(); for (int i = 0; i < p; i++) { // int a = 0; // for (int j = 0; j < 4; j++) { // int o = getchar(); // o -= '0'; // cout << ">>" << o << endl; // a *= 10; // a += o; // } // int c = getchar(); // c = getchar(); // c -= '0'; // a *= 10; // a += c; // c = getchar(); // int a,b; // cin >> a >> " - "; // cout << a; // cin >> b; // cout << b; // a *= 10; // a += b; char a[7]; cin >> a; // cout << a << endl; a[4] = a[5]; a[5] = 0; int b = atoi(a); double v = 0; scanf("%lf\n", &v); u.zaloz(b, v); // cout << a << " : "<< v ;aaa(v); cout << endl; } char st[10]; st[0] = getchar(); int a,c; char ch[7]; double v; bool en = true; // cout << st << endl; while (en) { //cout << st[0]; switch (st[0]) { case 'c': // scanf("%d/%d\n",&a,&b); // a *= 10; // a += b; cin.ignore(6); cin >> ch; ch[4] = ch[5]; ch[5] = 0; a = atoi(ch); // cin >> v; cin.ignore(); u.pridej(a); break; case 'd': cin.ignore(7); // scanf("%d/%d %f\n",&a,&b,&v); // a *= 10; // a += b; cin >> ch; ch[4] = ch[5]; ch[5] = 0; a = atoi(ch); cin >> v; // cout << "a: " << a << endl; // cout << "v: " << v ;aaa(v); cout << endl; u.vloz(a,v); cin.ignore(); break; case 'w': //cout << "okok" << endl; // scanf("%d/%d %f\n",&a,&b,&v); // a *= 10; // a += b; cin.ignore(8); cin >> ch; ch[4] = ch[5]; ch[5] = 0; a = atoi(ch); cin >> v; u.vyber(a,v); // cout << "a: " << a << endl; // cout << "v: " << v ;aaa(v); cout << endl; // return 1; cin.ignore(); break; case 't':cin.ignore(8); /* scanf("%d/%d %d/%d %f\n",&a,&b,&c,&d,&v); a *= 10; a += b; c *= 10; c += d;*/ cin >> ch; ch[4] = ch[5]; ch[5] = 0; a = atoi(ch); cin >> ch; ch[4] = ch[5]; ch[5] = 0; c = atoi(ch); cin >> v; u.trans(a,v,c); cin.ignore(); break; default: cin.ignore(4); cout << "end\n\n" ;en = false; } if (en) st[0]=getchar(); } cin >> p; // cout << "p" << p <