Re: [問題] 請問如何寫出奇偶分離合併程式
※ 引述《realmeat (真肉)》之銘言:
: ※ 引述《psplay (亂世中一個小小書僮)》之銘言:
: public static String shuffffffffffffle(String in){
: if(in == null) return null;
: int len = in.length();
: StringBuilder strBuilder = new StringBuilder();
: for(int i=0; i<len; i++){
: int k = 0;
: if(i % 2 == 0){
: k = i >>> 1;
: }else{
: k = (len + i - 1 + 2*(len%2)) >>> 1 ;
: }
: strBuilder.append(in.substring(k, k));
: }
: return strBuilder.toString();
: }
: 請享用
純粹好奇, 這樣寫是單純想搞原po還是平常真的就用這種方式寫code?
例如今天題目突然變成切三等份後洗牌 (原本是切兩等分)
不就等於要重寫? 甚至維護的人會看不懂?
順便借這個機會問問大家 clean code 的粒度會到多細 ?
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 123.193.192.133
※ 文章網址: http://www.ptt.cc/bbs/java/M.1412249818.A.FF9.html
→
10/02 20:10, , 1F
10/02 20:10, 1F
推
10/02 23:38, , 2F
10/02 23:38, 2F
→
10/02 23:38, , 3F
10/02 23:38, 3F
→
10/02 23:39, , 4F
10/02 23:39, 4F
→
10/02 23:40, , 5F
10/02 23:40, 5F
推
10/02 23:42, , 6F
10/02 23:42, 6F
→
10/02 23:48, , 7F
10/02 23:48, 7F
推
10/02 23:59, , 8F
10/02 23:59, 8F
→
10/03 00:00, , 9F
10/03 00:00, 9F
→
10/03 00:00, , 10F
10/03 00:00, 10F
推
10/03 00:42, , 11F
10/03 00:42, 11F
→
10/03 00:42, , 12F
10/03 00:42, 12F
→
10/03 00:45, , 13F
10/03 00:45, 13F
推
10/03 00:48, , 14F
10/03 00:48, 14F
→
10/03 00:49, , 15F
10/03 00:49, 15F
→
10/03 00:50, , 16F
10/03 00:50, 16F
→
10/03 00:51, , 17F
10/03 00:51, 17F
→
10/03 00:51, , 18F
10/03 00:51, 18F
→
10/03 00:51, , 19F
10/03 00:51, 19F
推
10/03 00:56, , 20F
10/03 00:56, 20F
推
10/03 00:57, , 21F
10/03 00:57, 21F
→
10/03 00:57, , 22F
10/03 00:57, 22F
→
10/03 00:57, , 23F
10/03 00:57, 23F
→
10/03 00:59, , 24F
10/03 00:59, 24F
→
10/03 01:00, , 25F
10/03 01:00, 25F
→
10/03 01:01, , 26F
10/03 01:01, 26F
→
10/03 01:01, , 27F
10/03 01:01, 27F
推
10/03 01:14, , 28F
10/03 01:14, 28F
推
10/03 01:23, , 29F
10/03 01:23, 29F
推
10/03 01:36, , 30F
10/03 01:36, 30F
推
10/03 01:43, , 31F
10/03 01:43, 31F
→
10/03 09:37, , 32F
10/03 09:37, 32F
推
10/03 09:47, , 33F
10/03 09:47, 33F
討論串 (同標題文章)
java 近期熱門文章
PTT數位生活區 即時熱門文章