alexa-tracking

Main Content

1024
1024
KASKUS
51
244
https://www.kaskus.co.id/thread/531ff91e118b46e5548b457d/mohon-bantu-buat-flowchart-dengan-visio-2007
Mohon bantu buat flowchart dengan visio 2007
<?php
function cocktailSort($arr){
if (is_string($arr)) $arr = str_split(preg_replace('/\s+/','',$arr));
do{
$swapped = false;
for($i=0;$i<count($arr);$i++){
if(isset($arr[$i+1])){
if($arr[$i] > $arr[$i+1]){
list($arr[$i], $arr[$i+1]) = array($arr[$i+1], $arr[$i]);
$swapped = true;
}
}
}
if ($swapped == false) break;
$swapped = false;
for($i=count($arr)-1;$i>=0;$i--){
if(isset($arr[$i-1])){
if($arr[$i] < $arr[$i-1]) {
list($arr[$i],$arr[$i-1]) = array($arr[$i-1],$arr[$i]);
$swapped = true;
}
}
}
}
while($swapped);
return $arr;
}
$arr = array(5, 1, 7, 3, 6, 4, 2);
$arr2 = array("John", "Kate", "Alice", "Joe", "Jane", "Berry", "Benny", "Cherry");
$strg = "test cocktail sort";
$arr = cocktailSort($arr);
$arr2 = cocktailSort($arr2);
$strg = cocktailSort($strg);
echo implode(',',$arr) . '<br>';
echo implode(',',$arr2) . '<br>';
echo implode('',$strg) . '<br>';
?>

mohon bagi yang mengerti tolong ya gan?
ane bener2 gak ngerti bikinnya