JAVA選択ソート

1048 ワード

/*
        :
        3 1 6 2 5
        
          :     ,                  。
*/
public class SelectSort{
    
    public static void main(String[] args){
        
        int[] a = {3 ,1 ,6 ,2 ,5};
        
        //    
        for(int i=0;ia[j]){
                    // min    
                    min = j;
                }
            }
            
            //      .
            if(min != i){
                int temp;
                temp = a[i];
                a[i] = a[min];
                a[min] = temp;
            }
            
        }
        
        //  
        for(int i=0;ia[j]){
                    int temp=a[j];
                    a[j]=a[i];
                    a[i]=temp;
                }
            }
        }
/*

3 1 6 2 5
     :
1 3 6 2 5

3 6 2 5
     :
2 6 3 5

6 3 5
     :
3 6 5

6 5
     :
5 6


*/