1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
int InsertSort(int arr[]) {
 
    for (int i = 1; i < SIZE; i++) {
        int CurrentValue = arr[i];
        int j = i;
        for (; j > 0; j--) {
            if (CurrentValue < arr[j - 1]) arr[j] = arr[j - 1];
            else break;
        }
 
        arr[j] = CurrentValue;
 
    }
 
    cout << " Insert Sort " << endl;
    Print(arr);
 
    return 0;
}
cs


'알고리즘' 카테고리의 다른 글

Find Min, Find Second  (0) 2018.05.26
SelectionSearch  (0) 2018.05.26
SelectionSort  (0) 2018.05.26
BubbleSort  (0) 2018.05.26
MergeSort  (0) 2018.05.26

+ Recent posts