#include #include #include struct ucet { bool aktivni; float castka; }; ucet ucty[500000]; bool act(int i) { return ucty[i].aktivni; } int main() { int pocet; char line[5200]; int ucet; int uc2; float m; int uc3; #define SL uc3 = ucet*10+uc2; #define NSA printf("no such account\n"); while(scanf("%d", &pocet)==1) { memset(ucty, 0, sizeof(ucty)); if (pocet == 0) { break; } //nacist konta for(int c = 0; c= m)) { ucty[uc3].castka-=m; printf("ok\n"); } else { printf( "insufficient funds\n"); } } else { NSA; } continue; } if (sscanf(line, "deposit %d/%d %f", &ucet, &uc2, &m ) == 3 ) { SL; printf("deposit %.2f: ", m); if((ucty[uc3].aktivni)) { ucty[uc3].castka += m; printf("ok\n"); } else { printf("no such account\n"); } continue; } int du1, du2, du3; if (sscanf(line, "transfer %d/%d %d/%d %f", &ucet, &uc2, &du1, &du2, &m ) == 5 ) { SL; du3 = du1*10+du2; printf("transfer %.2f: ", m); if(!(act(du3) && act(uc3))) { NSA; continue; } if(du3 == uc3) { printf("same account\n"); continue; } else if(ucty[uc3].castka < m) { printf("insufficient funds\n"); continue; } ucty[uc3].castka -= m; ucty[du3].castka += m; if(uc2 != du2) { printf("interbank\n"); } else { printf("ok\n"); } continue; } if (sscanf(line, "create %d/%d", &ucet, &uc2 ) == 2 ) { SL; printf("create: "); if(act(uc3)) { printf("already exists\n"); } else { ucty[uc3].aktivni = true; printf("ok\n"); } continue; } } printf("end\n\n"); fgets(line, 5000, stdin);//one empty line } printf("goodbye\n"); return 0; }