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


¾Ë°í¸®Áò - ¼±Åà Á¤·Ä
<?
$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 0$i $n -1$i++  ){
        
$MinIndex $i;

        for( 
$j  $MinIndex$j $n$j++ ){

            if( 
$AA[$MinIndex] > $AA[$j] ){
                
$Tmp            =    $AA[$MinIndex];
                
$AA[$MinIndex]    =    $AA[$j];
                
$AA[$j]            =    $Tmp;
                
$Tmp            =    "";
            }

        }
        
    }    
 
 
?>

30 20 40 10 5 10 30 15

for( $i = 0; $i < $n -1; $i++ ){

    $MinIndex = $i;

    for( $j = $MinIndex; $j < $n; $j++ ){

        if( $AA[$MinIndex] > $AA[$j] ){
            $Tmp = $AA[$MinIndex];
            $AA[$MinIndex] = $AA[$j];
            $AA[$j] = $Tmp;
            $Tmp = "";
        }

    }

}

5 10 10 15 20 30 30 40