Re: [問題] 字串排列最大值

看板C_and_CPP (C/C++)作者 (nahgnimiast)時間16年前 (2009/03/05 01:34), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串4/4 (看更多)
: { : if( *(str1 + pos) == 0 ) : return CompareInt( *str1, *(str2 + pos) ); : if( *(str2 + pos) == 0 ) : return CompareInt( *(str1 + pos), *str2 ); : if( ( res = CompareInt(*(str1 + pos), *(str2 + pos) ) ) == 0 ) : pos++; : else : return res; 剛才想了一下 上面的比較對於 123 123123000會出問題。 所以乾脆把 短字串重複複制到跟長字串長度一樣後,再用strcmp比 不過要動記憶體的話好像很更慢 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 218.167.99.246 ※ 編輯: tsaiminghan 來自: 218.167.99.246 (03/05 01:35) ※ 編輯: tsaiminghan 來自: 218.167.99.246 (03/05 01:42)

03/05 16:52, , 1F
嗯..謝謝
03/05 16:52, 1F
文章代碼(AID): #19hhkVRM (C_and_CPP)
文章代碼(AID): #19hhkVRM (C_and_CPP)