#include #include #include #include using namespace std ; int main() { int account[1100] ; double amount[1100], p ; int count, tmp, aux, help ; char dummy ; bool exist; string s ; while (true) { (cin >> count).get() ; if (count == 0) break ; for (int i = 0 ; i < count ; i++) { getline(cin, s) ; istringstream is(s) ; is >> account[i] ; is >> dummy ; is >> tmp ; is >> amount[i] ; account[i] *= 10 ; account[i] += tmp ; } while (true) { getline(cin, s) ; istringstream is(s) ; is >> s ; if (!strcmp(s.c_str(), "end")) { cout << "end" << endl << endl ; break ; } if (!strcmp(s.c_str(), "create")) { is >> tmp ; is >> dummy ; is >> aux ; tmp *= 10 ; tmp += aux ; exist = false ; for (int i = 0 ; i < count ; i++) { if (account[i] == tmp) { exist = true ; break ; } } if (exist) cout << "create: already exists" << endl ; else { cout << "create: ok" << endl ; account[count] = tmp ; amount[count++] = 0 ; } } else if (!strcmp(s.c_str(), "withdraw")) { is >> tmp ; is >> dummy ; is >> aux ; tmp *= 10 ; tmp += aux ; is >> p ; exist = false ; for (int i = 0 ; i < count ; i++) { if (account[i] == tmp) { if (amount[i] >= p) { amount[i] -= p ; cout << "withdraw " << setprecision(2) << fixed << p << ": ok" << endl ; } else { cout << "withdraw " << setprecision(2) << fixed << p << ": insufficient funds" << endl ; } exist = true ; break ; } } if (!exist) cout << "withdraw " << setprecision(2) << fixed << p << ": no such account" << endl ; } else if (!strcmp(s.c_str(), "deposit")) { is >> tmp ; is >> dummy ; is >> aux ; tmp *= 10 ; tmp += aux ; is >> p ; exist = false ; for (int i = 0 ; i < count ; i++) { if (account[i] == tmp) { amount[i] += p ; cout << "deposit " << setprecision(2) << fixed << p << ": ok" << endl ; exist = true ; break ; } } if (!exist) cout << "deposit " << setprecision(2) << fixed << p << ": no such account" << endl ; } else if (!strcmp(s.c_str(), "transfer")) { is >> tmp ; is >> dummy ; is >> aux ; tmp *= 10 ; tmp += aux ; is >> aux ; is >> dummy ; is >> help ; aux *= 10 ; aux += help ; is >> p ; exist = false ; bool exist2 = false ; for (int i = 0 ; i < count ; i++) { if (account[i] == tmp) { exist = true ; break ; } } for (int i = 0 ; i < count && exist ; i++) { if (account[i] == aux) { exist2 = true ; break ; } } if (exist && exist2) { exist = true ; if (tmp != aux) { for (int i = 0 ; i < count ; i++) { if (account[i] == tmp) { if (amount[i] < p) { cout << "transfer " << setprecision(2) << fixed << p << ": insufficient funds" << endl ; exist = false ; } else amount[i] -= p ; break ; } } if (exist) { for (int i = 0 ; i < count ; i++) { if (account[i] == aux) { amount[i] += p ; break ; } } if (tmp % 10 == aux % 10) { cout << "transfer " << setprecision(2) << fixed << p << ": ok" << endl ; } else cout << "transfer " << setprecision(2) << fixed << p << ": interbank" << endl ; } } else { cout << "transfer " << setprecision(2) << fixed << p << ": same account" << endl ; } } else cout << "transfer " << setprecision(2) << fixed << p << ": no such account" << endl ; } } } cout << "goodbye" << endl ; return 0 ; }