Created
October 25, 2013 01:25
-
-
Save jeonghwan-kim/7148081 to your computer and use it in GitHub Desktop.
insert sort
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void insert_sort(int a[], int n) { | |
| for (int i=1; i<n; i++) { | |
| int temp = a[i]; | |
| // 정렬되어 있는 배열의 경우 루프를 실행하지 않는다. | |
| for (int j=i; j>0 && a[j-1] > a[j]; j--) { | |
| a[j] = a[j-1]; | |
| a[j-1] = temp; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment