병합정렬2 [알고리즘] 병합 정렬 - C++ 병합 정렬 #include using namespace std; int temp[6]; int arr[] = { 4, 2, 6, 1, 5, 3 }; void merge(int start, int end) { int mid = (start + end) / 2; int i = start, j = mid + 1, k = start; while (i 2021. 9. 22. [알고리즘] 버블 정렬 - C++ 버블 정렬 #include using namespace std; int arr[] = {4, 2, 6, 1, 5, 3}; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL), cout.tie(NULL); for (int i = 0; i arr[j + 1]){//붙어있는 두 값을 비교하여 왼쪽보다 오른쪽이 작을 경우 int temp = arr[j];//자리 바꿈 arr[j] = arr[j + 1]; arr[j + 1] = temp; } } } for (int i=0; i < 6; i++) cout 2021. 9. 22. 이전 1 다음