k20k #8327(2009/01/13 19:42 GMT) [ 秀丸マクロ ] Rating0/0=0.00
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
$goal="Q"; $pipe[0]="-"; $pipe[1]="|"; #route=1; #hier=0; #houkou=0; gofiletop; while( 1==1 ) { if( #houkou==0 || #houkou==1 ) { call rightdown #houkou; #ret=##return; if( #ret==1 ) { #rd[#hier]=#houkou; #pnt[#hier]=#pnt[#hier]+1; #hier=#hier+1; #houkou=0; continue; } #houkou=#houkou+1; } else { if( char(code)!=$goal ) { #route = #route+#pnt[#hier]-1; } #pnt[#hier]=0; #hier=#hier-1; #houkou=#rd[#hier]+1; if( #hier==-1 ) break; call gowhere #rd[#hier]+2; call gowhere #rd[#hier]+2; continue; } } message( str(#route) ); endmacro; rightdown: call gowhere ##1; if( char(code)==$pipe[##1] ) { call gowhere ##1; return 1; } call gowhere ##1+2; return 0; gowhere: if( ##1==0 ) right; if( ##1==1 ) down; if( ##1==2 ) left; if( ##1==3 ) up; return;
Rating0/0=0.00-0+
1 reply [ reply ]
k20k #8327() [ 秀丸マクロ ] Rating0/0=0.00
再帰処理が使えないので、自前で階層処理(#hier関連)を実装しました。
なので、処理がちょっと冗長に...
$goal="Q"; $pipe[0]="-"; $pipe[1]="|"; #route=1; #hier=0; #houkou=0; gofiletop; while( 1==1 ) { if( #houkou==0 || #houkou==1 ) { call rightdown #houkou; #ret=##return; if( #ret==1 ) { #rd[#hier]=#houkou; #pnt[#hier]=#pnt[#hier]+1; #hier=#hier+1; #houkou=0; continue; } #houkou=#houkou+1; } else { if( char(code)!=$goal ) { #route = #route+#pnt[#hier]-1; } #pnt[#hier]=0; #hier=#hier-1; #houkou=#rd[#hier]+1; if( #hier==-1 ) break; call gowhere #rd[#hier]+2; call gowhere #rd[#hier]+2; continue; } } message( str(#route) ); endmacro; rightdown: call gowhere ##1; if( char(code)==$pipe[##1] ) { call gowhere ##1; return 1; } call gowhere ##1+2; return 0; gowhere: if( ##1==0 ) right; if( ##1==1 ) down; if( ##1==2 ) left; if( ##1==3 ) up; return;Rating0/0=0.00-0+
1 reply [ reply ]