Re: [問題] 遞迴的問題 謝謝
※ 引述《drey (drey)》之銘言:
: 不好意思打擾大家了
: 想請問大家
: 一般的插入排序我看的懂會寫
: 但如果要換成遞迴的插入排序法
: 該怎麼寫呢
: 謝謝
大概是像這樣的程式結構:
sort(result, source) {
if source = "" then
return result
else
one = source[0]
others = source[1..]
insert(result, one)
return sort(result, others)
}
insert(result, one)是在排序的result中找到好位置插入one.
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.231.64.207
討論串 (同標題文章)
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章