LinuxÒÁµéÔ°ÂÛ̳'s Archiver

smartmouse ·¢±íÓÚ 2006-3-3 09:39

¡¾Ô­´´¡¿Ã°ÅÝÅÅÐòµÄPHPʵÏÖ

[PHP]
<?php
function BubbleSort($str)
{
for ($i=0;$i<count($str);$i++)
{       
        for ($j=count($str)-2;$j>=$i;$j--)
        {
                        if($str[$j+1]<$str[$j])
                        {   
                                $tmp = $str[$j+1];
                               
                                $str[$j+1]=$str[$j];
                                $str[$j]=$tmp;
                        }

        }

}
return $str;
}
$str = array(3,6,1,5,9,0,4,6,11);
print_r(BubbleSort($str));
?>

[/PHP]

Ò³: [1]

Powered by Discuz! Archiver 6.1.0  © 2001-2007 Comsenz Inc.