±À¤¶:| Web Hosting | Cloud Server | Server Hosting | Server Colocation | Responsive Web design | Bob·AUr pnt½G¨­¤TÄ_ | Email Hosting Service | English course |

µo·s¸ÜÃD
¥´¦L

请问谁À´PHP°Ú?±æ赐±Ð

请问谁À´PHP°Ú?±æ赐±Ð

¦p¦ó¥ÎPHP写¤@个ªí达¦¡,结ªGRETURNªº¬O©Ò¦³¥Ñ1,2,3,4组¦¨ªº¥]§t4个¤¸¯Àªº¥þ³¡组¦X.
§Y: («ç样¥i¥H让µ{§Ç写¥X¦p¤U±Æ¦C)
1,2,3,4
1,2,4,3
1,3,2,4
1,3,4,2
.....
.....
4,3,2,1

±æ°ª¤â«ü点,谢谢

TOP

¤£会¬O§@业§a¡H

给§A个³Ì°ò¥»ªº¡A还¥i¥H¤@¨Ç§ó聪©úªº¤èªk¤ñ¦p¥Îbitwiseªº¤è¦¡¡A¦Û¤v¥h¬ã¨s§a¡C

for ($a=1; $a<5; $a++) {
    for ($b=1; $b<5; $b++) {
        for ($c=1; $c<5; $c++) {
            for ($d=1; $d<5; $d++) {
                printf("%d, %d, %d, %d", $a,$b,$c,$d);
            }
        }
    }
}

TOP

¤Þ¥Î:
­ì©«¥Ñ fsnow ©ó 2007-10-24 22:27 µoªí
给§AŸÄ³Ì°ò¥»ªº¡A还¥i¥H¤@¨Ç§ó聪©úªº¤èªk¤ñ¦p¥Îbitwiseªº¤è¦¡¡A¦Û¤v¥h¬ã¨s§a¡C

for ($a=1; $a<5; $a++) {
    for ($b=1; $b<5; $b++) {
        for ($c=1; $c<5; $c++)  ...
®Ú¾Ú»Õ¤Uªº·½¥N½X, ¿é¥X±N·|­«ÂЪº¼Æ¦r¥X²{¦p:
1, 1, 1, 1
1, 1, 1, 2
1, 1, 1, 3
...
IT¥N¤u/Âò¤â¤@¦W!
¤p§Ì¨Ã­ø¥­, ¦ýµ´­ø«Y¶Q!

TOP

Oh¡A ©êºp©êºp~~没¦³¬Ý²M问题¡C

这个¨ä实´N¬OBubble sort¹À~¥u¤£过­n§â³q±`ªº从¤p¨ì¤jªº±Æ§Ç¤è¦¡¤Ï过来¦Ó¤w¡C给§A个link¦Û¤v试试¬Ý«£~

http://en.wikipedia.org/wiki/Bubble_sort

TOP

¦^´_ #4 fsnow ªº©«¤l

À³¸Ó«Y·Q­n©Ò¦³ "combinations" (nCr).

TOP

µo·s¸ÜÃD


­«­nÁn©ú¡G¥»°Q½×°Ï¬O¥H§Y®É¤W¸ü¯d¨¥ªº¤è¦¡¹B§@¡A¥»ºô¯¸¹ï©Ò¦³¯d¨¥ªº¯u¹ê©Ê¡B§¹¾ã©Ê¤Î¥ß³õµ¥¡A¤£­t¥ô¦óªk«ß³d¥ô¡C¦Ó¤@¤Á¯d¨¥¤§¨¥½×¥u¥Nªí¯d¨¥ªÌ­Ó¤H·N¨£¡A¨Ã«D¥»ºô¯¸¤§¥ß³õ¡A¥Î¤á¤£À³«H¿à¤º®e¡A¨ÃÀ³¦Û¦æ§PÂ_¤º®e¤§¯u¹ê©Ê¡C©ó¦³Ãö±¡§Î¤U¡A¥Î¤áÀ³´M¨D±M·~·N¨£(¦p¯A¤ÎÂåÀø¡Bªk«ß©Î§ë¸êµ¥°ÝÃD)¡C¥Ñ©ó¥»°Q½×°Ï¨ü¨ì¡u§Y®É¤W¸ü¯d¨¥¡v¹B§@¤è¦¡©Ò³W­­¡A¬G¤£¯à§¹¥þºÊ¹î©Ò¦³¯d¨¥¡A­YŪªÌµo²{¦³¯d¨¥¥X²{°ÝÃD¡A½ÐÁpµ¸§Ú­Ì¡C¥»°Q½×°Ï¦³Åv§R°£¥ô¦ó¯d¨¥¤Î©Úµ´¥ô¦ó¤H¤h¤W¸ü¯d¨¥¡A¦P®É¥ç¦³¤£§R°£¯d¨¥ªºÅv§Q¡C¤Á¤Å¼¶¼g²Ê¨¥Â©»y¡B½ÚÁ½¡B´è¬V¦â±¡¼É¤O©Î¤H¨­§ðÀ»ªº¨¥½×¡A·q½Ð¦Û«ß¡C¥»ºô¯¸«O¯d¤@¤Áªk«ßÅv§Q¡C


Copyright 1997- Xocat. All Right Reserved.