1
0
Fork 0
This commit is contained in:
Arthur K. 2025-05-29 19:24:43 +03:00
commit 810a9654a4
Signed by: wzray
GPG key ID: B97F30FDC4636357
50 changed files with 4450 additions and 0 deletions

49
2/A.cpp Normal file
View file

@ -0,0 +1,49 @@
#include <iostream>
void PrintArray(const int* arr, const int* size);
void SortArray(int* arr, const int* size);
void PrintArray(const int* arr, const int* size) {
for (int i = 0; i < *size; ++i) {
std::cout << arr[i] << " ";
}
std::cout << std::endl;
}
void SortArray(int* arr, const int* size) {
if (*size == 1)
return;
int i, j, idx;
idx = 0;
i = idx;
j = 1;
while (idx < *size) {
while (arr[i] > arr[j]) {
std::swap(arr[i], arr[j]);
if (i == 0)
break;
--j;
--i;
}
i = idx;
j = ++idx;
}
}
int main() {
int size;
std::cin >> size;
int* a = new int[size];
for (int i = 0; i < size; ++i) {
std::cin >> a[i];
}
SortArray(a, &size);
PrintArray(a, &size);
return 0;
}