#include <iostream>
using namespace std;
int main()
{
int arr[8] = { 83, 72, 65, 54, 47, 33, 29, 1 };
int i = 1;
int j, k;
do {
int front = arr[i];
j = i - 1;
do {
int back = arr[j];
k = j + 1;
if (front < back)
{
int tmp = arr[k];
arr[k] = arr[j];
arr[j] = tmp;
}
else if (front >= back)
{
j = -1;
}
j--;
} while (j >= 0);
i++;
for (int l = 0; l < 8; l++) { cout << arr[l] << ' '; }
cout << endl;
} while (i < 8);
}
'끄적끄적' 카테고리의 다른 글
C++ Link (0) | 2023.08.16 |
---|---|
Insertion Sort (Lisp) (0) | 2022.05.01 |
Iterative Quicksort (C++) (0) | 2022.05.01 |