#include #include #include #include using namespace std; double p[1100]; map ucty; int main() { int u, uc1, uc2, ut1, ut2; int in; char pr[100]; double h; while(scanf("%d", &u) != EOF) { in = 1; ucty.clear(); if (!u) { printf("goodbye\n"); return 0; } for (int i = 0; i < 1100; i++) { p[i] = -1; } for (int i = 0; i < u; i++) { scanf("%d/%d %lf", &uc1, &uc2, &h); ucty[uc1*10+uc2] = in; p[in] = h; p[ucty[uc1*10+uc2]] = round(p[ucty[uc1*10+uc2]]*100)/double (100); in++; } scanf("%s", pr); while(pr[0] != 'e') { if (pr[0] == 'w') { scanf("%d/%d %lf", &uc1, &uc2, &h); printf("withdraw %.2lf: ", h ); if (p[ucty[uc1*10+uc2]] == -1) { printf("no such account\n"); } else if (p[ucty[uc1*10+uc2]] < h) { printf("insufficient funds\n"); } else { p[ucty[uc1*10+uc2]] -= h; p[ucty[uc1*10+uc2]] = round(p[ucty[uc1*10+uc2]]*100)/double(100); printf("ok\n"); } } else if (pr[0] == 'c') { scanf("%d/%d", &uc1, &uc2); printf("create: "); if (p[ucty[uc1*10+uc2]] != -1) { printf("already exists\n"); } else { ucty[uc1*10+uc2] = in; p[in] = 0; in++; printf("ok\n"); } } else if (pr[0] == 'd') { scanf("%d/%d %lf", &uc1, &uc2, &h); printf("deposit %.2lf: ", h); if (p[ucty[uc1*10+uc2]] == -1) { printf("no such account\n"); } else { p[ucty[uc1*10+uc2]] += h; p[ucty[uc1*10+uc2]] = round(p[ucty[uc1*10+uc2]]*100)/double (100); printf("ok\n"); } } else if (pr[0] == 't') { scanf("%d/%d %d/%d %lf", &uc1, &uc2, &ut1, &ut2, &h); printf("transfer %.2lf: ", h); if (p[ucty[uc1*10+uc2]] == -1) { printf("no such account\n"); } else if (p[ucty[ut1*10+ut2]] == -1) { printf("no such account\n"); } else if(uc2 == ut2 && uc1 == ut1) { printf("same account\n"); } else if (p[ucty[uc1*10+uc2]] < h) { printf("insufficient funds\n"); } else { p[ucty[ut1*10+ut2]] += h; p[ucty[uc1*10+uc2]] -= h; p[ucty[uc1*10+uc2]] = round(p[ucty[uc1*10+uc2]]*100)/double (100); p[ucty[ut1*10+ut2]] = round(p[ucty[ut1*10+ut2]]*100)/double (100); if (uc2 == ut2) { printf("ok\n"); } else { printf("interbank\n"); } } } scanf("%s",pr); } printf("end\n\n"); } return 0; }