//--------------------------------------------------------------------------- //Движение каретки вправо TForm1::right() { if(a < 600) { Canvas->Brush->Color = clBlack ; kar(a); Canvas->Brush->Color = clBlue ; kar(a+20); } }
//--------------------------------------------------------------------------- //Движение каретки влево TForm1::left() { if(a > 0) { Canvas->Brush->Color = clBlack ; kar(a); Canvas->Brush->Color = clBlue ; kar(a-20); } }
//--------------------------------------------------------------------------- //Старт игры и отрисовка начального положения кубиков, каретки, шарика void __fastcall TForm1::Button1Click(TObject *Sender) { gameover = 84 ; x = 80 ; Canvas->Pen->Color = clRed; Canvas->Brush->Color = clBlack; Canvas->Rectangle(0,0,635,480); Canvas->Brush->Color = clYellow; Canvas->Pen->Color = clBlack; for (int i = 0; i < 12 ; i++) { y=40; for (int j = 0; j < 7 ; j++) { Canvas->Rectangle(x,y,x+35,y+15); mas[i][j].e = x; mas[i][j].r = y; y = y+20; } x = x+40; } int k; Canvas->Brush->Color = clBlue ; kar(300); randomize; n = random(5)*10+300; m = 400; switch (random(2)) { case(0) : f=-1; d=1; break; case(1) : f=-1; d=-1; break; } krug(1); Button1 -> Enabled = false; }
void funcall(object fun) { /* object VOL sfirst=NULL; */ /* wipe_stack(&sfirst); */ /* { */ object temporary=OBJNULL; object x=OBJNULL; object * VOL top=NULL; object *lex=NULL; bds_ptr old_bds_top=NULL; VOL bool b=0; bool c=0; DEBUG_AVMA TOP: if (fun == OBJNULL) FEerror("Undefined function.", 0); switch (type_of(fun)) { /* case t_cfun: */ /* MMcall(fun); */ /* CHECK_AVMA; return; */ case t_function: {int i=Rset; if (!i) {ihs_check;ihs_push(fun);} quick_call_function(fun); if (!i) ihs_pop(); } return; case t_symbol: { object x = fun->s.s_gfdef; if (x!=OBJNULL) { fun = x; goto TOP;} else FEundefined_function(fun); } /* case t_ifun: */ /* { */ /* object x = fun->ifn.ifn_self; */ /* if (x) { fun = x; /\* ihs_check;ihs_push(fun); *\/break;} */ /* else */ /* FEundefined_function(fun); */ /* } */ case t_cons: if (fun->c.c_car!=sLlambda && fun->c.c_car!=sLlambda_closure && fun->c.c_car!=sLlambda_block && fun->c.c_car!=sSlambda_block_expanded && fun->c.c_car!=sLlambda_block_closure) FEinvalid_function(fun); break; default: FEinvalid_function(fun); } /* This part is the same as that of funcall_no_event. */ /* we may have pushed the calling form if this is called invoked from eval. A lambda call requires vs_push's, so we can tell if we pushed by vs_base being the same. */ { VOL int not_pushed = 0; if (vs_base != ihs_top->ihs_base){ ihs_check; ihs_push(fun); } else not_pushed = 1; ihs_top->ihs_base = lex_env; x = MMcar(fun); top = vs_top; lex = lex_env; old_bds_top = bds_top; /* maybe digest this lambda expression (lambda-block-expand name ..) has already been expanded. The value of lambda-block-expand may be a compiled function in which case we say expand with it) */ if (x == sSlambda_block_expanded) { b = TRUE; c = FALSE; fun = fun->c.c_cdr; } else if (x == sLlambda_block) { b = TRUE; c = FALSE; if(sSlambda_block_expanded->s.s_dbind!=OBJNULL) fun = ifuncall1(sSlambda_block_expanded->s.s_dbind,fun); fun = fun->c.c_cdr; } else if (x == sLlambda_closure) { b = FALSE; c = TRUE; fun = fun->c.c_cdr; } else if (x == sLlambda) { b = c = FALSE; fun = fun->c.c_cdr; } else if (x == sLlambda_block_closure) { b = c = TRUE; fun = fun->c.c_cdr; } else b = c = TRUE; if (c) { vs_push(kar(fun)); fun = fun->c.c_cdr; vs_push(kar(fun)); fun = fun->c.c_cdr; vs_push(kar(fun)); fun = fun->c.c_cdr; } else { *(struct nil3 *)vs_top = three_nils; vs_top += 3; } if (b) { x = kar(fun); /* block name */ fun = fun->c.c_cdr; } lex_env = top; vs_push(fun); lambda_bind(top); ihs_top->ihs_base = lex_env; if (b) { fun = temporary = alloc_frame_id(); /* lex_block_bind(x, temporary); */ temporary = MMcons(temporary, Cnil); temporary = MMcons(sLblock, temporary); temporary = MMcons(x, temporary); lex_env[2] = MMcons(temporary, lex_env[2]); frs_push(FRS_CATCH, fun); if (nlj_active) { nlj_active = FALSE; goto END; } } x = top[3]; /* body */ if(endp(x)) { vs_base = vs_top; vs_push(Cnil); } else { top = vs_top; for (;;) { eval(MMcar(x)); x = MMcdr(x); if (endp(x)) break; vs_top = top; } } END: if (b) frs_pop(); bds_unwind(old_bds_top); lex_env = lex; if (not_pushed == 0) {ihs_pop();} CHECK_AVMA; } }
int main(int argc, char *argv[]) { srand(time(NULL)); int i,j; big result = 0; if (argc!=2 && argc!=3 && argc!=4) { printf("Usage: ./kk filename [mode] [rep]"); return 1; } int flag = 0; int rep = 0; big *list; if (argc==2) { list = malloc(100*sizeof(big)); char *filename = argv[1]; FILE *fp = fopen(filename,"r"); for (i=0;i<100;i++) { fscanf(fp,"%llu\n",&list[i]); } result = kar(list); printf("Residue: %llu\n",result); } if (argc==3) { big res[6]; for (i=0;i<6;i++) res[i] = 0; big kres = 0; list = malloc(100*sizeof(big)); for(i=0;i<50;i++) { gen(list,100); for (flag=0;flag<3;flag++) { for (rep=0;rep<2;rep++) { res[3*rep+flag]+=run_kk(list,flag,rep); } } kres += kar(list); } for (i=0;i<6;i++) res[i] = res[i]/50; kres = kres/50; printf("Rep: std, Mode: rep. rand. --> avg. result: %llu\n",res[0]); printf("Rep: std, Mode: hill climb --> avg. result: %llu\n",res[1]); printf("Rep: std, Mode: sim. anneal --> avg. result: %llu\n",res[2]); printf("Rep: alt, Mode: rep. rand. --> avg. result: %llu\n",res[3]); printf("Rep: alt, Mode: hill climb --> avg. result: %llu\n",res[4]); printf("Rep: alt, Mode: sim. anneal --> avg. result: %llu\n",res[5]); printf("Regular Karm-Karp --> avg. result: %llu\n", kres); } if (argc==4) { list = malloc(100*sizeof(big)); flag = atoi(argv[2]); rep = atoi(argv[3]); if (rep == 2) { gen(list,100); result=kar(list); } for (i=0;i<50;i++) { gen(list,100); result += run_kk(list,flag,rep); } result = result/50; printf("Avg. Residue: %llu\n",result); } free(list); return 0; }