Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Java¶þ·Ö·¨

Ìù¶Î´úÂë,ÓÐÉÙÐí×¢ÊÍ:
package ibees;
import java.util.Arrays;
public class BinarySearch {

/**
* @param args
*/
public static void main(String[] args) {
double[] src = new double[]{1.3,9.9,10.89,12.89,89.0};
System.out.println(new BinarySearch().binarySearch(src, 89.0));
}

/**
* ¶þ·Ö·¨²éÕÒ
* */
public int binarySearch(double[] src, double des){
Arrays.sort(src);
int beginIndex = 0;
int endIndex = src.length-1;
int middle = (endIndex+beginIndex)/2;

while(src[middle] != des && beginIndex != endIndex){

//×îºóÁ½Ïî
if(beginIndex+1 == endIndex){
if(src[beginIndex] == des){
return beginIndex;
}else if(src[endIndex] == des){
return endIndex;
}else{
return -1;
}

}

//ÅжÏÖмäµÄÊýÓë¸ø¶¨ÊýÖ®¼äµÄ¹Øϵ
if(des > src[middle]){
beginIndex = middle+1;
}else if(des < src[middle]){
endIndex = middle-1;
}else{
return middle;
}

middle = (endIndex + beginIndex)/2;

}
return middle;
}
}

ÏëÏë·µ»ØµÄÊý×éË÷ÒýÊDz»¶ÔµÄ¡£


Ïà¹ØÎĵµ£º

JavaÓëģʽ£ºÈ±Ê¡ÊÊÅäÆ÷ģʽ¡¾×ª×Ôwww.bitsCN.com¡¿

ÉÏÎÄ̸µ½ÁËÊÊÅäÆ÷ģʽ£¬ÒªÊÇTargerÄ¿±ê½ÇÉ«ÓÐ20·½·¨£¬ÄÇôÿ¸öÊÊÅäÆ÷¶¼ÒªÈ¥ÊµÏÖ½Ó¿ÚÖÐÕâЩ·½·¨£¬ÕâÑù×ö¸Ð¾õÌ«·Ñ¾¢¡£     ÕâÖÖÇé¿öÏ£¬¿ÉÒÔ¿¼ÂÇʵÏÖ¸öĬÈÏÊÊÅäÆ÷£¬È»ºóʵ¼ÊµÄʵÏÖÄ¿±ê½ÇÉ«½Ó¿ÚµÄÀà¿ÉÒÔ¼¯³ÉÕâ¸öĬÈÏÊÊÅäÆ÷£¬È»ºóÖØдĬÈÏʵÏֵķ½·¨¼´¿É¡£     Ò»¡¢Ô­Àíͼ   ......

javaÏîÄ¿ java webÏîÄ¿Êý¾Ý¿âÂÒÂëÎÊÌâµÄ½â¾ö°ì·¨

×÷Ϊjava²ËÄñ£¬ÔÚѧϰµ½Êý¾Ý¿â²Ù×÷µÄʱºòÍùÍù»áÓöµ½Ò»¸öºÜÍ·Í´µÄÎÊÌ⣬Êý¾Ý¿âÖÐÎÄÂÒÂë¡£ÕâËƺõÊÇÿ¸öjava³ÌÐòÔ±Ôڳɳ¤¹ý³ÌÖж¼»áÓöµ½µÄÎÊÌ⣬ÏÂÃæÎҾͰÑÎÒ×Ô¼ºµÄ¼¸ÖÖ·½·¨ºÍ´ó¼Ò·ÖÏíһϡ££¨Ò»°ãÊÇÔÚMyEclipseÏ¿ª·¢£©
javaÏîÄ¿£º
Ê×ÏÈ£¬È·±£ÏîÄ¿µÄ±àÂëÊÇgbk»òutf-8(),ÔÚWindows->Preferences->General->Workplac ......

Êý¾Ý¿âResultSetÏê½â£¨java£©

ÕâƪÎÄÕ²¢Ã»Óиø³öÈçºÎʹÓÃResultSetµÄ¾ßÌåÀý×Ó£¬Ö»ÊÇ´ÓResultSetµÄ¹¦ÄÜÐÔÉϽøÐÐÁËÏêϸµÄ½²Êö¡£Ï£ÍûÕâƪÎÄÕ¶Դó¼ÒÀí½âResultSetÄܹ»ÓÐËù°ïÖú¡£ÏÂÃæ¾ÍÊÇÕâƪÎÄÕµľßÌåÄÚÈÝ¡£
         ½á¹û¼¯(ResultSet)ÊÇÊý¾ÝÖвéѯ½á¹û·µ»ØµÄÒ»ÖÖ¶ÔÏ󣬿ÉÒÔ˵½á¹û¼¯ÊÇÒ»¸ö´æ´¢²éѯ½á¹ûµÄ¶ÔÏó£ ......

ÓÃultraEdit±àÒëºÍÖ´ÐÐjava³ÌÐò

£¨1£©Ìí¼Ó±àÒëjava²Ëµ¥
1¡¢´ò¿ª ¸ß¼¶£­>¹¤¾ßÅäÖÃ
2¡¢ÔÚ“ÃüÁîÀ¸”ÀïÊäÈë javac %n%e £¨%nΪÎļþÃû²»´øÀ©Õ¹Ãû£¬%eΪÀ©Õ¹Ãû£©
3¡¢ÔÚ“¹¤×÷Ŀ¼”ÉÏÌî %p (±íʾÎļþËùÔÚĿ¼)
4¡¢ÔÚ“²Ëµ¥ÏîÄ¿Ãû³Æ”ÉÏÊäÈë ±àÒëjava³ÌÐò £¨ÏÖÔÚÔڲ˵¥ÉϵÄÃû³Æ£©
5¡¢Ñ¡Ôñ“±£´æµ±Ç°Îļþ”¸´Ñ¡¿ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ