Java ¼¸ÖÖÅÅÐò·¨
ÕâÀïÖ÷Òª¶Ô8ÖÖÅÅÐòËã·¨×ö¸ö×ܽᣬ·Ö±ðÊDzåÈëÅÅÐò£¬Ñ¡ÔñÅÅÐò£¬Ã°ÅÝÅÅÐò£¬Ï£¶ûÅÅÐò£¬¹é²¢ÅÅÐò£¬¶ÑÅÅÐò£¬¿ìËÙÅÅÐòÒÔ¼°»ùÊýÅÅÐò¡£
1¡¢ ²åÈëÅÅÐò
±È½ÏºÍ½»»»µÄʱ¼ä¸´ÔÓ¶ÈΪO(n^2)£¬Ëã·¨×ÔÊÊÓ¦£¬¶ÔÓÚÊý¾ÝÒÑ»ù±¾ÓÐÐòµÄÇé¿ö£¬Ê±¼ä¸´ÔÓ¶ÈΪO(n)£¬Ëã·¨Îȶ¨£¬¿ªÏúºÜµÍ£¬ÊʺÏÓÚÊý¾ÝÒÑ»ù±¾ÓÐÐò»òÕßÊý¾ÝÁ¿Ð¡µÄÇé¿ö¡£
public void insertionSort() {// ²åÈëÅÅÐò
int out, in;
int count1 = 0, count2 = 0;// ¸´ÖÆ´ÎÊý£¬±È½Ï´ÎÊý
for (out = 1; out < nElems; out++) {
long temp = a[out];
in = out;
boolean flag=in>0&&a[in-1]>=temp;
while(flag){
if(a[in-1]>=temp){
if(in>0){
a[in]=a[in-1];
count1++;
--in;
}
}
count2++;
flag=in>0&&a[in-1]>=temp;
}
a[in] = temp;
}
System.out.println("¸´ÖÆ´ÎÊýΪ£º" + count1 + " ±È½Ï´ÎÊýΪ£º" + count2);
}
2¡¢ Ñ¡ÔñÅÅÐò
Ëã·¨²»Îȶ¨£¬O(1)µÄ¶îÍâµÄ¿Õ¼ä£¬±È½ÏµÄʱ¼ä¸´ÔÓ¶ÈΪO(n^2)£¬½»»»µÄʱ¼ä¸´ÔÓ¶ÈΪO(n)£¬²¢²»ÊÇ×ÔÊÊÓ¦µÄ¡£ÔÚ´ó¶àÊýÇé¿ö϶¼²»ÍƼöʹÓá£Ö»ÓÐÔÚÏ£Íû¼õÉÙ½»»»´ÎÊýµÄÇé¿öÏ¿ÉÒÔÓá£
public void selectionSort(){//Ñ¡ÔñÅÅÐò
int out, in, min;
for(out=0;out<nElems-1;out++){
min=out;
for(in=out+1;in<nElems;in++){
if(a[in]<a[min]){
min=in;
}
swap(out,min);
}
}
}
3¡¢ ðÅÝÅÅÐò
Ëã·¨Îȶ¨£¬O(1)µÄ¶îÍâµÄ¿Õ¼ä£¬±È½ÏºÍ½»»»µÄʱ¼ä¸´ÔӶȶ¼ÊÇO(n^2)£¬×ÔÊÊÓ¦£¬¶ÔÓÚÒÑ»ù±¾ÅÅÐòµÄËã·¨£¬Ê±¼ä¸´ÔÓ¶ÈΪO(n)¡£Ã°ÅÝËã·¨µÄÐí¶àÐÔÖʺͲåÈëËã·¨ÏàËÆ£¬µ«¶ÔÓÚϵͳ¿ªÏú¸ßÒ»µãµã¡£
public void bubbleSort() {// ðÅÝÅÅÐò£¬µ¥Ïî
int out, in;
Ïà¹ØÎĵµ£º
ÏßÐÔ±í£¬Á´±í£¬¹þÏ£±íÊdz£ÓõÄÊý¾Ý½á¹¹£¬ÔÚ½øÐÐJava¿ª·¢Ê±£¬JDKÒѾΪÎÒÃÇÌṩÁËһϵÁÐÏàÓ¦µÄÀàÀ´ÊµÏÖ»ù±¾µÄÊý¾Ý½á¹¹¡£ÕâЩÀà¾ùÔÚjava.util°üÖС£±¾ÎÄÊÔͼͨ¹ý¼òµ¥µÄÃèÊö£¬Ïò¶ÁÕß²ûÊö¸÷¸öÀàµÄ×÷ÓÃÒÔ¼°ÈçºÎÕýȷʹÓÃÕâЩÀà¡£
Collection
©ÀList& ......
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
public class Lunar {
private int year;
private int month;
private int day;
private boolean leap;
......
½ñÌìÓÃÁËÒ»ÏÂJAVAÖеÄJDOM£¬JDOM ÊÇÒ»ÖÖʹÓà XML µÄ¶ÀÌØ Java ¹¤¾ß°ü£¬ÓÃÓÚ¿ìËÙ¿ª·¢ XML Ó¦ÓóÌÐò¡£
ÔÚÒÔÏÂÕâÀïÄܹ»¿´µ½¸üÏêϸµÄ¶ÔJDOMµÄ½éÉÜ£º
http://www.ibm.com/developerworks/cn/java/j-jdom/
ÏÂÃæÊÇÎÒ×Ô¼ºµÄ¹ØÓÚдXMLÎļþ¼°¶ÁXMLÎļþµÄ´úÂ룺
дXMLÎļþ
import org.jdom.*;
import org.jdom.output.XMLOutputt ......
¼ÙÉèÐèÇó(ÈçÓÐÀ×ͬ£¬´¿ÊôÇɺÏ)£º
ÓÐÒ»¸öÈ«¹úÐԵĴóÆóÒµ£¬ÔÚÈ«¹ú¸÷µØÐèÒª²¿ÊðÉÏǧ̨¿Í»§»ú£¬ÕâЩ¿Í»§»úÐèҪʵʱÓë·þÎñÆ÷½»»¥£¬½øÐÐÊý¾Ý´¦Àí¡£ÊµÊ±ÐÔÒªÇó¸ß£¬°²È«ÐԸߣ¬ÒªÇóÖ§³ÖÊÂÎñ£¬ÒÔ¼°²»ÖжϷþÎñ¡£
Ó²¼þ²¿Êð£º
1¡¢ 3000̨¿Í»§»ú
2¡¢ 10̨· ......
James Óʼþ·þÎñÆ÷µÄ°²×°ºÍÅäÖÃ
»·¾³:
Óʼþ·þÎñÆ÷:
²Ù×÷ϵͳ:REDHAT LINUX AS 4
IP:192.168.1.108
×ÓÍøÑÚÂë:255.255.0
Íø¹Ø:192.168.1.1
DNS:192.168.1.2
¿Í»§¶Ë:
²Ù×÷ϵͳ:windows 2003
IP :192.168.1.2
×ÓÍøÑÚÂë:255.255.255.0
Íø¹Ø:192.168.1.1
DNS:192.168.1.2
¼òµ¥½éÉÜÒ»ÏÂÓʼþ·þÎñÆ÷µÄÅäÖû·¾³
ÒѾ° ......