´ÓÒ»¸ö¼òµ¥Java³ÌÐòÀ´Ì¸Ì¸Öع¹
Õâ¸öÖ÷ÌâÊǹØÓÚ±àÂëµÄһЩÔÔòºÍģʽµÄ£¬ÓÃÕâЩ¿ÉÒÔ°ïÖú³ÌÐòÔ±´´½¨¸ü¼ÓÁé»îºÍ¾ßÓÐÊÊÓ¦ÐÔµÄÈí¼þÄ£¿é¡£
±ÊÕßÏÂÃæÒýÓõijÌÐòÊÇRobert´óÊåÖøÃûµÄ³ÌÐòƬ¶ÏÀ´ÖØÐÂÈÏʶһÏÂÖع¹£¬ÄÇЩjava´úÂë¿´ÆðÀ´ÕýÈ·£¬µ«ÊÂʵÉϲ»ÊÇ¿´ÆðÀ´ÄÇô¼òµ¥µÄ£¬Ò»Ð¡¶Î³ÌÐòµ÷ÊÔÆðÀ´×Ü»áÓÐЩС´íÎó¡£ÎÒÒ»¶È»³ÒÉÊÇ×÷Õß»òÒëÕß¹ÊÒâȥд´íһЩ´úÂ룬ȻºóÒýÆðÔĶÁÕßµÄ×¢ÒâµÄ¡£´Ó³ÌÐòµÄµ÷ÊÔ±àдÒÔ¼°Öع¹¹ý³ÌÖУ¬±¸×¢ÁË×÷ΪһÃûÒ»Ïß³ÌÐòÔ±µÄһЩ×ܽᡣ
“Öع¹”£¬¹ËÃû˼Ò壬¶Ô³ÌÐòÀ´Ëµ¾ÍÊÇ“ÔÚ²»¸Ä±ä´úÂëÍâÔÚÐÐΪµÄÇ°Ìá϶ԴúÂë×ö³öÐ޸ģ¬ÒԸĽø´úÂëÄÚ²¿½á¹¹µÄ¹ý³Ì”¡£
ÏÂÃæÊÇÒ»¸öËØÊý²úÉú³ÌÐò£¬Ê×ÏÈÒªÖªµÀʲôÊÇËØÊý°É£¿¼ÇµÃÉÏѧʱÊéÉÏ˵ËØÊý¾ÍÊÇÖÊÊý£¬ÊdzýÁËÄܱ»1ºÍ±¾ÉíÕû³ýÍ⣬ûÓÐÆäËûÒò×ÓÄÜÕû³ý¡£ÓÖgoogleÁËÏ£¬Æ䶨ÒåÈçÏ£º
1.Ö»ÓÐ1ºÍËü±¾ÉíÕâÁ½¸öÒòÊýµÄ×ÔÈ»Êý½Ð×öËØÊý¡£»¹¿ÉÒÔ˵³ÉËØÊýÖ»ÓÐ1ºÍËü±¾ÉíÁ½¸öÔ¼Êý¡£
2.ËØÊýÊÇÕâÑùµÄÕûÊý£¬Ëü³ýÁËÄܱíʾΪËü×Ô¼ººÍ1µÄ³Ë»ýÒÔÍ⣬²»ÄܱíʾΪÈκÎÆäËüÁ½¸öÕûÊýµÄ³Ë»ý¡£
ÀýÈ磬15£½3×5£¬ËùÒÔ15²»ÊÇËØÊý.
´Ó±à³Ì½Ç¶ÈÎÒÃÇÒª¿¼ÂÇÆäËã·¨£¬Ëã·¨ÊÇʲô£¿Ëã·¨²ÉÓÃSieve of Eratosthenesɸѡ·¨£¬Õâ¸öËã·¨µÄÏêϸÇé¿öÊÇÕâÑùµÄ£º
ÓÉÓÚÒ»¸öºÏÊý(Ïà¶ÔÓÚËØÊýµÄ¶¨Ò壬¼´0ºÍ1Ö®Í⣬³ýÁËËØÊý¾ÍÊǺÏÊý)×ÜÊÇ¿ÉÒÔ·Ö½â³ÉÈô¸É¸öËØÊýµÄ³Ë»ý£¬ÄÇôÈç¹û°ÑËØÊý(×î³õÖ»ÖªµÀ2ΪËØÊý)µÄ±¶Êý¶¼È¥µô£¬ÄÇôʣϵľÍÊÇËØÊýÁË¡£
ÀýÈçÒª²éÕÒ100ÒÔÄÚµÄËØÊý£¬Ê×ÏÈ2ÊÇÖÊÊý£¬°Ñ2µÄ±¶ÊýÈ¥µô£»´Ëʱ3ûÓб»È¥µô£¬¿ÉÈÏΪÊÇËØÊý£¬ËùÒÔ°Ñ3µÄ±¶ÊýÈ¥µô£»ÔÙµ½5£¬ÔÙµ½7£¬Ö®ºóÄØÒòΪ8£¬9£¬10¸Õ¶¼±»È¥µôÁË£¬¶ø100ÒÔÄÚµÄÈÎÒâºÏÊý¿Ï¶¨¶¼ÓÐÒ»¸öÒò×ÓСÓÚ10(100µÄ¿ª·½)¡£Òò´ËÈ¥µô2£¬3£¬5£¬7µÄ±¶ÊýºóʣϵĶ¼ÊÇËØÊýÁË¡£
ÏÂÃæ³ÌÐòµÄÖ÷ÒªÂ߼Ƭ¶ÏÊÇ:
//×îÖ÷ÒªÂß¼ÔÚÓÚ´Ë£¬Math.sqrt(s)È¡µÃ¸ÃÊýλÓÚÖмäµÄÒò×Ó.
//±ÈÈçmaxValue=10,ÄÇôMath.sqrt(s)=3
for(i=2;
Ïà¹ØÎĵµ£º
¹Ø¼üÓï¾ä£º
conn.setAutoCommit(false);
if(!ok) conn.rollBack();
// after all done
conn.commit();
conn.setAutoCommit(true);
ǧÍò±ðÍü¼ÇÒª¼Óconn.commit()·ñÔò²»»áÖ´ÐÐÊÂÎñµÄ¡£
ÁíÍ⣬M ......
public class Calendar {
/**
* Ö±½ÓµÄ¿ÉÒԲ鿴Ч¹û
* @param args
*/
public static void main(String[] args) {
int year=input.nextInt();//Äê
int month=input.nextInt();//ÔÂ
int yearday=0;//Äê×ÜÌìÊý
//¼ ......
< type="text/javascript"> ÖÚËùÖÜÖª£¬ÔÚ³ÌÐò¿ª·¢ÖУ¬ÄÑÃâ»áÓöµ½ÐèҪƥÅä¡¢²éÕÒ¡¢Ìæ»»¡¢ÅжÏ×Ö·û´®µÄÇé¿ö·¢Éú£¬¶øÕâЩÇé¿öÓÐʱÓֱȽϸ´ÔÓ£¬Èç¹ûÓô¿±àÂ뷽ʽ½â¾ö£¬ÍùÍù»áÀ˷ѳÌÐòÔ±µÄʱ¼ä¼°¾«Á¦¡£Òò´Ë£¬Ñ§Ï°¼°Ê¹ÓÃÕýÔò±í´ïʽ£¬±ã³ÉÁ˽â¾öÕâһì¶ÜµÄÖ÷ÒªÊֶΡ£
´ó ¼Ò¶¼ÖªµÀ£¬ÕýÔò±í´ïʽÊÇÒ»ÖÖ¿ÉÒÔÓÃÓÚÄ£Ê ......
annotationʹÓÃ
2010Äê2ÔÂ11ÈÕ ÁɹúÅÖÅÖ
½ñÌì¿´annotation¹æ·¶£¬ÌؼǼÈçÏ£¬ÒÔ±ãÒÔºó²Î¿¼£¬Ò²¹©³õѧµÄÅóÓÑÃÇÒ»¸ö¿ÉÔËÐа¸Àý£¬Óв»Í×Ö®´¦£¬ÇëÖ¸ÕýÐ޸ģ»ÁíÍ⣬ÌرðÉùÃ÷£¬Èç¹ûתÔØ»òÕßÒýÓÃÇë×¢Ã÷³ö´¦¡£
½éÉÜ
AnnotationÊÇjava5ÐÂÌí¼ÓµÄÌØÐÔ£¬ annotationÊÇÒ»ÖÖÔªÊý¾ ......
ÔÚJava ÖÐÊý¾ÝÀàÐ͵Ä×Ô¶¯×ª»»ÀÏÊdzöÏÖһЩÎÊÌâ
byte b1 =1 , b2 = 12; //Äܹ»Í¨¹ý
byte b3 = 128 //±àÒëµÄʱºò²»ÄÜͨ¹ý
ÎÒÃÇÖªµÀJavaÖÐÊý¾ÝÀàÐÍbyte shout char ÔÚ½øÐмÆËãµÄʱºò¶¼ÊÇ» ......