#include typedef struct { char cu[11]; int value; int actphase; } ucet; ucet ucty[20000]; int nuc=0; char comm[1000],buf2[1000],buf3[1000],buf4[1000]; int phase=0; int total=0; #define P 26431 ucet *huc[P]; int amount(char *s) { int n,d; sscanf(s,"%d.%d",&n,&d); return 100*n+d; } char *form(char *buf,int val) { int n,d; n=val/100; d=val%100; sprintf(buf,"%d.%02d",n,d); return buf; } int hfce(char *w) { int ret=0; while (*w) { ret=(ret*23+(*w-'0'))%P; w++; } return ret; } ucet *find(char *co) { int from=hfce(co); while (huc[from]&&huc[from]->actphase==phase) { if (!strcmp(co,huc[from]->cu)) return huc[from]; from=(from+1)%P; } huc[from]=NULL; return NULL; } void insert(char *co,ucet *as) { int from=hfce(co); while (huc[from]&&huc[from]->actphase==phase) { if (!strcmp(co,huc[from]->cu)) break; from=(from+1)%P; } huc[from]=as; } void zaloz(char *uct) { ucet *uc=find(uct); if (uc) { printf("Ucet %s uz existuje.\n\n",uct); return; } ucty[nuc].value=0; ucty[nuc].actphase=phase; strcpy(ucty[nuc].cu,uct); insert(uct,ucty+nuc); nuc++; printf("Ucet %s vytvoren.\n\n",uct); } char pb[100],pb1[100]; void uloz(char *uct,int val) { ucet *uc=find(uct); if (!uc) { printf("Ucet %s neexistuje.\n\n",uct); return; } uc->value+=val; total+=val; printf("Ulozeno %s na ucet %s.\n\n",form(pb,val),uct); } void vyber(char *uct,int val) { ucet *uc=find(uct); if (!uc) { printf("Ucet %s neexistuje.\n\n",uct); return; } if (uc->valuevalue-=val; total-=val; printf("Vybrano %s z uctu %s.\n\n",form(pb,val),uct); } void preved(char *uct,char *to,int val) { ucet *uc=find(uct); ucet *ucto=find(to); if (!uc) { printf("Ucet %s neexistuje.\n",uct); } else if (uc->valuevalue-=val; ucto->value+=val; printf("Prevedeno %s z uctu %s na ucet %s.\n\n",form(pb,val),uct,to); } void stat() { printf("Pocet uctu: %d\nCelkem: %10s\n\n",nuc,form(pb,total)); } void list() { int i; printf("Pocet uctu: %d\n",nuc); for (i=0;i