¾Ë°í¸®Áò ¸ÞÀÎÀ¸·Î À̵¿~!!!


¾Ë°í¸®Áò - »ðÀÔ Á¤·Ä
<?
$AA 
= array(30,20,40,10,5,10,30,15);

 
    for( 
$i 0$i count($AA); $i++ ){
        echo 
$AA[$i]."   ";
    }

    
$n    =    count($AA);
    

    for( 
$i 2$i <= $n$i++  ){
        
$Value $AA[$i];
        
$j $i;

        While( 
$AA[$j 1] > $Value ){
            
$AA[$j] = $AA[$j 1];
            
$j--;
        }

        
$AA[$j] = $Value;
        
    }    
 
 
 
?>

30 20 40 10 5 10 30 15


for( $i = 2; $i <= $n; $i++ ){

    $Value = $AA[$i];
    $j = $i;

    While( $AA[$j - 1] > $Value ){
        $AA[$j] = $AA[$j - 1];
        $j--;
    }

    $AA[$j] = $Value;

}

5 10 10 15 30 20 30 40