作者superlubu (劲过吕布)
看板java
标题Re: [问题] JAVA
时间Thu Jul 12 16:31:47 2007
题外话... 这个 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