O(n^2)
error_reporting(E_ALL|E_STRICT);
ini_set('display_errors','on');
$length=rand(8,10);
for($i=0;$i<$length;$i++)
$a[]=rand(100,200);
for($i=0;$i
if($a[$j]<$a[$j-1]){
$tmp=$a[$j];
$a[$j]=$a[$j-1];
$a[$j-1]=$tmp;
}
}
}
foreach($a as $value)
echo $value."\n";
沒有留言:
張貼留言