なあ、再帰関数好きな人いる? パート3 [転載禁止]©2ch.net
1デフォルトの名無しさん
2015/11/28(土) 18:51:38.86ID:Rc2MJzM/ なあ、再帰関数好きな人いる?
576NAS6 ◆n3AmnVhjwc
2016/01/05(火) 07:31:25.96ID:FnNfbNzM stk =Array.new()
#同色上書き塗りつぶし
def loop_refill(dest,src,x,y,color,minx,miny,maxx,maxy)
term = 0
while !((x < minx) || (maxx < x) ||(y < miny) || (maxy < y))
dest[y][x] = color
#上
if (term < 1) && (src[y-1][x] == color) && (dest[y-1][x] != color)
term = 0
stk.push(x)
stk.push(y)
stk.push(term)
y = y - 1
term = 0
next
end
#左
if (term < 2) && (src[y][x-1] == color) && (dest[y][x-1] != color)
term = 1
stk.push(x)
stk.push(y)
stk.push(term)
x = x - 1
term = 0
next
end
#同色上書き塗りつぶし
def loop_refill(dest,src,x,y,color,minx,miny,maxx,maxy)
term = 0
while !((x < minx) || (maxx < x) ||(y < miny) || (maxy < y))
dest[y][x] = color
#上
if (term < 1) && (src[y-1][x] == color) && (dest[y-1][x] != color)
term = 0
stk.push(x)
stk.push(y)
stk.push(term)
y = y - 1
term = 0
next
end
#左
if (term < 2) && (src[y][x-1] == color) && (dest[y][x-1] != color)
term = 1
stk.push(x)
stk.push(y)
stk.push(term)
x = x - 1
term = 0
next
end
577NAS6 ◆n3AmnVhjwc
2016/01/05(火) 07:31:53.09ID:FnNfbNzM #下
if (term < 3) && (src[y+1][x] == color) && (dest[y+1][x] != color)
term = 2
stk.push(x)
stk.push(y)
stk.push(term)
y = y + 1
term = 0
next
end
#右
if (term < 4) && (src[y][x+1] == color) && (dest[y][x+1] != color)
term = 3
stk.push(x)
stk.push(y)
stk.push(term)
x = x + 1
term = 0
next
end
term = stk.pop()
y = stk.pop()
x = stk.pop()
end
end
if (term < 3) && (src[y+1][x] == color) && (dest[y+1][x] != color)
term = 2
stk.push(x)
stk.push(y)
stk.push(term)
y = y + 1
term = 0
next
end
#右
if (term < 4) && (src[y][x+1] == color) && (dest[y][x+1] != color)
term = 3
stk.push(x)
stk.push(y)
stk.push(term)
x = x + 1
term = 0
next
end
term = stk.pop()
y = stk.pop()
x = stk.pop()
end
end
レスを投稿する
ニュース
- 【速報】流行語年間大賞に高市早苗首相「働いて働いて働いて働いて働いてまいります/女性首相」 [Ailuropoda melanoleuca★]
- モーニングショーで女性弁護士、「世界中の国を見渡しても日本ほど中国ともめている国は今はどこもない」「挑発しちゃっている状況」 [muffin★]
- 高市首相「いいから黙って全部オレに投資しろ」“進撃の巨人”のセリフで対日投資呼びかけ [おっさん友の会★]
- 【流行語大賞】2025 T&D保険グループ新語・流行語大賞、高市早苗首相の「働いて働いて働いて働いて働いて」が年間大賞! [煮卵★]
- 【おこめ】ベトナムから密輸のコメを「国産」と偽り販売容疑、ベトナム人ら2人追送検…300トン売って1億3000万円稼いだか 大阪 [ぐれ★]
- 【速報】長期金利、一時1.850%に上昇 ★2 [蚤の市★]
- たしかにネトウヨの巨大化は把握してたけど、まさか2025年にここまで一気に気持ち悪い国になると思ってた? [452836546]
- 青山繁晴環境副大臣「南鳥島のレアアースは、中国産の約20倍の純度がある」 [834922174]
- 高市早苗ちゃん。 流行語大賞をゲット [485983549]
- 人○してぇ
- 【悲報】立憲「トンデモ論者に乗っ取られた高市政権」高橋洋一「プリンストン大時代のオレの先生はノーベル経済学賞受賞なのでよろしく [733893279]
- わい、なろうにハマリすぎてなろうみたいな食生活になる
