#include #include long accttonr(int a1, int a2) { if ((a1 * 10) + a2 > 99999) return 0; return (a1 * 10) + a2; } int main() { int accts[100005]; float bal[100005]; int a; int a1, a2; int c1, c2; float b; char action[15]; long long run = 0; for (int i = 0; i < 100005; i++) { accts[i] = 0; } while (1) { run++; scanf("%d", &a); if (a == 0) { printf("goodbye\n"); return 0; } for (int i = 0; i < a; i++) { scanf("%d/%d %f", &a1, &a2, &b); accts[accttonr(a1, a2)] = run; bal[accttonr(a1, a2)] = b; } while (1) { scanf("%s", action); if (strcmp(action, "end") == 0) { printf("end\n\n"); break; } if (strcmp(action, "deposit") == 0) { scanf("%d/%d %f", &a1, &a2, &b); if (accts[accttonr(a1, a2)] == run) { bal[accttonr(a1, a2)] += b; printf("deposit %.2f: ok\n", b); } else { printf("deposit %.2f: no such account\n", b); } } if (strcmp(action, "withdraw") == 0) { scanf("%d/%d %f", &a1, &a2, &b); if (accts[accttonr(a1, a2)] == run) { if (bal[accttonr(a1, a2)] >= b) { bal[accttonr(a1, a2)] -= b; printf("withdraw %.2f: ok\n", b); } else { printf("withdraw %.2f: insufficient funds\n", b); } } else { printf("withdraw %.2f: no such account\n", b); } } if (strcmp(action, "transfer") == 0) { scanf("%d/%d %d/%d %f", &a1, &a2, &c1, &c2, &b); if ((accts[accttonr(a1, a2)] == run) && (accts[accttonr(c1, c2)] == run)) { if ((a1 == c1) && (a2 == c2)) { printf("transfer %.2f: same account\n", b); } else if (bal[accttonr(a1, a2)] >= b) { bal[accttonr(a1, a2)] -= b; bal[accttonr(c1, c2)] += b; if (a2 == c2) { printf("transfer %.2f: ok\n", b); } else { printf("transfer %.2f: interbank\n", b); } } else { printf("transfer %.2f: insufficient funds\n", b); } } else { printf("transfer %.2f: no such account\n", b); } } if (strcmp(action, "create") == 0) { scanf("%d/%d", &a1, &a2); if (accts[accttonr(a1, a2)] == run) { printf("create: already exists\n"); } else { printf("create: ok\n"); accts[accttonr(a1, a2)] = run; bal[accttonr(a1, a2)] = 0; } } } } return 0; }