#include #include #include using namespace std; int readmoney() { int i,f; char c; cin >> i >> c >> f; // cout << i << " " << f << endl; return i*100+f; } string printmoney(int money) { stringstream s; int i = money / 100; int f = money % 100; s << i << "."; if (f<10) s << "0"; s << f; return s.str(); } string getrest() { char nullchar; cin >> nullchar; string line; getline(cin,line); return line; } string getrestbezdvojtecky() { char nullchar; // cin >> nullchar; string line; getline(cin,line); return line; } string genacc(int i, int j) { stringstream s; s << i << "/" << j; return s.str(); } int main() { string line; while (cin) { stringstream s; int last_acc_no = 1000; map accounts; accounts["1111/2"]=0; //procreate a vydra accounts["3333/2"]=0; //deposit inter accounts["9999/1"]=0; //deposit while (true) { string cmd; cin >> cmd; //cout << cmd; if (cmd == "end") { s << "end" << endl << endl; break; } if (cmd == "goodbye") { cout << "0" << endl; return 0; } if (cmd == "create:") { string line = getrestbezdvojtecky(); if (line == " ok") { s << "create " << genacc(last_acc_no++,1) << endl; } else { s << "create " << "1111/2" << endl; } } else { int money = readmoney(); string line = getrest(); //cout << line << endl; if (cmd == "withdraw") { if (line == " ok") { string acc = genacc(last_acc_no++, 1); accounts[acc] = 1000000; s << "withdraw " << acc << " " << printmoney(money) << endl; } else if (line == " no such account") { s << "withdraw 2222/2 " << printmoney(money) << endl; } else { s << "withdraw 1111/2 " << printmoney(money) << endl; } } if (cmd == "deposit") { if (line == " no such account") { s << "deposit 2222/2 " << printmoney(money) << endl; } else { s << "deposit 3333/2 " << printmoney(money) << endl; } } if (cmd == "transfer") { if (line == " no such account") { s << "transfer 2222/2 1111/2 " << printmoney(money) << endl; } else if (line == " insufficient funds") { s << "transfer 1111/2 3333/2 " << printmoney(money) << endl; } else if (line == " same account") { s << "transfer 3333/2 3333/2 " << printmoney(money) << endl; } else if (line == " interbank") { string acc = genacc(last_acc_no++, 1); accounts[acc] = 1000000; s << "transfer " << acc << " 3333/2 " << printmoney(money) << endl; } else { string acc = genacc(last_acc_no++, 1); accounts[acc] = 1000000; s << "transfer " << acc << " 9999/1 " << printmoney(money) << endl; } } } } cout << accounts.size() << endl; map::iterator it = accounts.begin(); while (it!=accounts.end()) { cout << it->first << " " << printmoney(it->second) << endl; it++; } cout << s.str(); } // cout << "0" << endl; return 0; }