Re: [問題] JAVA

看板java作者 (勁過呂布)時間18年前 (2007/07/12 16:31), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/2 (看更多)
題外話... 這個 max function .... XD ※ 引述《dollow333 (打內SHOW)》之銘言: : public static int max(int compare1, int compare2, int compare3) { : int ascNumber[]={compare1, compare2, compare3}; : int bubbleTemp=-1; : for (int max1=0; max1<2; max1++) : for(int max2=max1+1; max2<3; max2++){ : if(ascNumber[max1]>ascNumber[max2]){ : bubbleTemp=ascNumber[max1]; : ascNumber[max1]=ascNumber[max2]; : ascNumber[max2]=bubbleTemp; : } : } : return ascNumber[2]; : } 其實可以這樣: int max = compare1; if (max < compare2) max = compare2; if (max < compare3) return compare3; return max; 除非題目注明一定要先用 bubble sort XD -- 很多人以為 所以我要 其實我是個快 我是大學生 告訴大家 三十歲的怪叔叔 ● ●/ ︿ ︿ /\ < ● ㄨ /\ ㄨ -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 147.8.130.225
文章代碼(AID): #16bURrGB (java)
討論串 (同標題文章)
文章代碼(AID): #16bURrGB (java)