Coding/Java 삽질기2009. 7. 10. 17:06

insertion sort 예제 :  http://chobocho.com/game/sort/insert_sort/insert_sort.html



 void insert_sort(int m_data[], int num)
 {
    int i = 0, j = 0, k = 0;
   
    for ( i = 1; i < num; i++ ) {
        k = m_data[i];
        for ( j = i - 1; j >= 0 && k > m_data[j]; j--) {
            m_data[j+1] = m_data[j];
        }
        m_data[j+1] = k;
   
     }
 }


update : 2010. 7. 10

'Coding > Java 삽질기' 카테고리의 다른 글

[Android] Speed Game  (0) 2009.10.13
Lifegame  (0) 2009.06.20
Android 설치  (0) 2009.05.25
Posted by chobocho