From a1e6df0af23e1247ce8d690cf7aa4018009c0248 Mon Sep 17 00:00:00 2001 From: Ksunyy <126989113+Ksunyy@users.noreply.github.com> Date: Sat, 21 Oct 2023 02:40:04 +0300 Subject: [PATCH 01/11] Add files via upload --- task3/Shvetsova.c | 78 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 task3/Shvetsova.c diff --git a/task3/Shvetsova.c b/task3/Shvetsova.c new file mode 100644 index 0000000..10ec5c5 --- /dev/null +++ b/task3/Shvetsova.c @@ -0,0 +1,78 @@ +#include +#include + +//-----------------ПУЗЫРЕК--------------------------------------------------- +// void sort(int arr[], int n) { +// for (int i = 0; i last) +// return; + +// while (l <= r) +// { +// while (array[l] < pivot) +// l++; +// while (array[r] > pivot) +// r--; +// if (l <= r) +// { +// int smth = array[l]; +// array[l] = array[r]; +// array[r] = smth; +// l++; +// r--; +// } +// } +// recurs(array, first, r); +// recurs(array, l, last); +// } + +// int main() { +// int n; +// scanf("%d", &n); +// int array[n]; +// for (int i = 0; i < n; i++) { +// scanf("%d", &array[i]); +// } +// recurs(array, 0, n); +// for (int i = 0; i < n; i++) { +// printf("%d ", array[i]); +// } +// return 0; +// } + +//-------------------------------------------------------------------------- From e2780347b21f9c37bfbd0f51d19effff19b4f6e2 Mon Sep 17 00:00:00 2001 From: Ksunyy <126989113+Ksunyy@users.noreply.github.com> Date: Sat, 21 Oct 2023 02:41:45 +0300 Subject: [PATCH 02/11] Shvetsova.c --- task3/Shvetsova.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/task3/Shvetsova.c b/task3/Shvetsova.c index 10ec5c5..1fc0d5f 100644 --- a/task3/Shvetsova.c +++ b/task3/Shvetsova.c @@ -68,7 +68,7 @@ // for (int i = 0; i < n; i++) { // scanf("%d", &array[i]); // } -// recurs(array, 0, n); +// recurs(array, 0, n-1); // for (int i = 0; i < n; i++) { // printf("%d ", array[i]); // } From afea1c44129c2ab90d408a2d24dacbb398480e2f Mon Sep 17 00:00:00 2001 From: Ksunyy <126989113+Ksunyy@users.noreply.github.com> Date: Sat, 21 Oct 2023 17:11:25 +0300 Subject: [PATCH 03/11] sort --- Shvetsova.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 Shvetsova.c diff --git a/Shvetsova.c b/Shvetsova.c new file mode 100644 index 0000000..f8ecdc7 --- /dev/null +++ b/Shvetsova.c @@ -0,0 +1,82 @@ +#include +#include + +//-----------------ПУЗЫРЕК--------------------------------------------------- +void sort(int arr[], int n) +{ + for (int i = 0; i < n; ++i) + { + for (int j = 0; j < n; ++j) + { + if (arr[i] <= arr[j]) + { + int c; + c = arr[i]; + arr[i] = arr[j]; + arr[j] = c; + } + } + } + return arr; +} +// -------------------------------------------------------------------------------- + +//-------------------БЫСТРАЯ------------------------------------------------------- +void recurs(int array[], int first, int last) +{ + + int l = first; + int r = last; + int pivot = array[(first + last) / 2]; + if (first > last) + return; + + while (l <= r) + { + while (array[l] < pivot) + l++; + while (array[r] > pivot) + r--; + if (l <= r) + { + int smth = array[l]; + array[l] = array[r]; + array[r] = smth; + l++; + r--; + } + } + recurs(array, first, r); + recurs(array, l, last); +} +// -------------------------------------------------------------------------------- + +int main() +{ + int n; + scanf("%d", &n); + int array[n]; + int array2[n]; + for (int i = 0; i < n; i++) + { + scanf("%d", &array[i]); + } + for (int j = 0; j < n; ++j) + { + array2[j] = array[j]; + } + recurs(array, 0, n - 1); + sort(array2, n); + printf("slow "); + for (int i = 0; i < n; i++) + { + printf("%d ", array[i]); + } + printf("\n"); + printf("fast "); + for (int s = 0; s < n; s++) + { + printf("%d ", array2[s]); + } + return 0; +} From 5ba85d6f176b4ade04e6655891e54dc6ebdb1c68 Mon Sep 17 00:00:00 2001 From: Ksunyy <126989113+Ksunyy@users.noreply.github.com> Date: Mon, 23 Oct 2023 09:35:41 +0300 Subject: [PATCH 04/11] Delete task3/Shvetsova.c --- task3/Shvetsova.c | 78 ----------------------------------------------- 1 file changed, 78 deletions(-) delete mode 100644 task3/Shvetsova.c diff --git a/task3/Shvetsova.c b/task3/Shvetsova.c deleted file mode 100644 index 1fc0d5f..0000000 --- a/task3/Shvetsova.c +++ /dev/null @@ -1,78 +0,0 @@ -#include -#include - -//-----------------ПУЗЫРЕК--------------------------------------------------- -// void sort(int arr[], int n) { -// for (int i = 0; i last) -// return; - -// while (l <= r) -// { -// while (array[l] < pivot) -// l++; -// while (array[r] > pivot) -// r--; -// if (l <= r) -// { -// int smth = array[l]; -// array[l] = array[r]; -// array[r] = smth; -// l++; -// r--; -// } -// } -// recurs(array, first, r); -// recurs(array, l, last); -// } - -// int main() { -// int n; -// scanf("%d", &n); -// int array[n]; -// for (int i = 0; i < n; i++) { -// scanf("%d", &array[i]); -// } -// recurs(array, 0, n-1); -// for (int i = 0; i < n; i++) { -// printf("%d ", array[i]); -// } -// return 0; -// } - -//-------------------------------------------------------------------------- From 4f537c7d72356f6e211f470395a2dab8e79bfa0d Mon Sep 17 00:00:00 2001 From: Ksunyy <126989113+Ksunyy@users.noreply.github.com> Date: Mon, 23 Oct 2023 09:36:40 +0300 Subject: [PATCH 05/11] Add files via upload --- task3/Shvetsova.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 task3/Shvetsova.c diff --git a/task3/Shvetsova.c b/task3/Shvetsova.c new file mode 100644 index 0000000..f8ecdc7 --- /dev/null +++ b/task3/Shvetsova.c @@ -0,0 +1,82 @@ +#include +#include + +//-----------------ПУЗЫРЕК--------------------------------------------------- +void sort(int arr[], int n) +{ + for (int i = 0; i < n; ++i) + { + for (int j = 0; j < n; ++j) + { + if (arr[i] <= arr[j]) + { + int c; + c = arr[i]; + arr[i] = arr[j]; + arr[j] = c; + } + } + } + return arr; +} +// -------------------------------------------------------------------------------- + +//-------------------БЫСТРАЯ------------------------------------------------------- +void recurs(int array[], int first, int last) +{ + + int l = first; + int r = last; + int pivot = array[(first + last) / 2]; + if (first > last) + return; + + while (l <= r) + { + while (array[l] < pivot) + l++; + while (array[r] > pivot) + r--; + if (l <= r) + { + int smth = array[l]; + array[l] = array[r]; + array[r] = smth; + l++; + r--; + } + } + recurs(array, first, r); + recurs(array, l, last); +} +// -------------------------------------------------------------------------------- + +int main() +{ + int n; + scanf("%d", &n); + int array[n]; + int array2[n]; + for (int i = 0; i < n; i++) + { + scanf("%d", &array[i]); + } + for (int j = 0; j < n; ++j) + { + array2[j] = array[j]; + } + recurs(array, 0, n - 1); + sort(array2, n); + printf("slow "); + for (int i = 0; i < n; i++) + { + printf("%d ", array[i]); + } + printf("\n"); + printf("fast "); + for (int s = 0; s < n; s++) + { + printf("%d ", array2[s]); + } + return 0; +} From d6c74cb100616de0c4176a4882fb811eea6bcd2f Mon Sep 17 00:00:00 2001 From: Ksunyy <126989113+Ksunyy@users.noreply.github.com> Date: Wed, 8 Nov 2023 17:47:18 +0300 Subject: [PATCH 06/11] Shvetsova sort --- task3/Shvetsova.c | 45 +++++---------------------------------------- 1 file changed, 5 insertions(+), 40 deletions(-) diff --git a/task3/Shvetsova.c b/task3/Shvetsova.c index f8ecdc7..c7ff059 100644 --- a/task3/Shvetsova.c +++ b/task3/Shvetsova.c @@ -1,28 +1,7 @@ #include #include - -//-----------------ПУЗЫРЕК--------------------------------------------------- -void sort(int arr[], int n) -{ - for (int i = 0; i < n; ++i) - { - for (int j = 0; j < n; ++j) - { - if (arr[i] <= arr[j]) - { - int c; - c = arr[i]; - arr[i] = arr[j]; - arr[j] = c; - } - } - } - return arr; -} -// -------------------------------------------------------------------------------- - //-------------------БЫСТРАЯ------------------------------------------------------- -void recurs(int array[], int first, int last) +void sort(int array[], int first, int last) { int l = first; @@ -46,37 +25,23 @@ void recurs(int array[], int first, int last) r--; } } - recurs(array, first, r); - recurs(array, l, last); + sort(array, first, r); + sort(array, l, last); } -// -------------------------------------------------------------------------------- int main() { int n; scanf("%d", &n); int array[n]; - int array2[n]; for (int i = 0; i < n; i++) { scanf("%d", &array[i]); } - for (int j = 0; j < n; ++j) - { - array2[j] = array[j]; - } - recurs(array, 0, n - 1); - sort(array2, n); - printf("slow "); + sort(array, 0, n); for (int i = 0; i < n; i++) { printf("%d ", array[i]); } - printf("\n"); - printf("fast "); - for (int s = 0; s < n; s++) - { - printf("%d ", array2[s]); - } return 0; -} +} \ No newline at end of file From a7b3fc97a7ac1e3fd0568bcf0523b0d8048633a2 Mon Sep 17 00:00:00 2001 From: Ksunyy <126989113+Ksunyy@users.noreply.github.com> Date: Wed, 8 Nov 2023 17:58:39 +0300 Subject: [PATCH 07/11] Delete task3/Shvetsova.c --- task3/Shvetsova.c | 47 ----------------------------------------------- 1 file changed, 47 deletions(-) delete mode 100644 task3/Shvetsova.c diff --git a/task3/Shvetsova.c b/task3/Shvetsova.c deleted file mode 100644 index c7ff059..0000000 --- a/task3/Shvetsova.c +++ /dev/null @@ -1,47 +0,0 @@ -#include -#include -//-------------------БЫСТРАЯ------------------------------------------------------- -void sort(int array[], int first, int last) -{ - - int l = first; - int r = last; - int pivot = array[(first + last) / 2]; - if (first > last) - return; - - while (l <= r) - { - while (array[l] < pivot) - l++; - while (array[r] > pivot) - r--; - if (l <= r) - { - int smth = array[l]; - array[l] = array[r]; - array[r] = smth; - l++; - r--; - } - } - sort(array, first, r); - sort(array, l, last); -} - -int main() -{ - int n; - scanf("%d", &n); - int array[n]; - for (int i = 0; i < n; i++) - { - scanf("%d", &array[i]); - } - sort(array, 0, n); - for (int i = 0; i < n; i++) - { - printf("%d ", array[i]); - } - return 0; -} \ No newline at end of file From 85a120f2874df557e7777f1e62004bd0691d4961 Mon Sep 17 00:00:00 2001 From: Ksunyy <126989113+Ksunyy@users.noreply.github.com> Date: Wed, 8 Nov 2023 17:59:26 +0300 Subject: [PATCH 08/11] Add files via upload --- task3/Shvetssova.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 task3/Shvetssova.c diff --git a/task3/Shvetssova.c b/task3/Shvetssova.c new file mode 100644 index 0000000..7e3e606 --- /dev/null +++ b/task3/Shvetssova.c @@ -0,0 +1,47 @@ +#include +#include + +void sort(int array[], int first, int last) +{ + + int l = first; + int r = last; + int pivot = array[(first + last) / 2]; + if (first > last) + return; + + while (l <= r) + { + while (array[l] < pivot) + l++; + while (array[r] > pivot) + r--; + if (l <= r) + { + int smth = array[l]; + array[l] = array[r]; + array[r] = smth; + l++; + r--; + } + } + sort(array, first, r); + sort(array, l, last); +} + +int main() +{ + int n; + scanf("%d", &n); + int array[n]; + for (int i = 0; i < n; i++) + { + scanf("%d", &array[i]); + } + sort(array, 0, n); + for (int i = 0; i < n; i++) + { + printf("%d ", array[i]); + } + return 0; +} \ No newline at end of file From 9a287fcb6bcdbf39cc856392df3efab98d4e5cac Mon Sep 17 00:00:00 2001 From: Ksunyy Date: Fri, 10 Nov 2023 14:27:21 +0300 Subject: [PATCH 09/11] Added --- Shvetsova.c | 82 ---------------------------------------------- task3/Shvetssova.c | 8 +++-- 2 files changed, 6 insertions(+), 84 deletions(-) delete mode 100644 Shvetsova.c diff --git a/Shvetsova.c b/Shvetsova.c deleted file mode 100644 index f8ecdc7..0000000 --- a/Shvetsova.c +++ /dev/null @@ -1,82 +0,0 @@ -#include -#include - -//-----------------ПУЗЫРЕК--------------------------------------------------- -void sort(int arr[], int n) -{ - for (int i = 0; i < n; ++i) - { - for (int j = 0; j < n; ++j) - { - if (arr[i] <= arr[j]) - { - int c; - c = arr[i]; - arr[i] = arr[j]; - arr[j] = c; - } - } - } - return arr; -} -// -------------------------------------------------------------------------------- - -//-------------------БЫСТРАЯ------------------------------------------------------- -void recurs(int array[], int first, int last) -{ - - int l = first; - int r = last; - int pivot = array[(first + last) / 2]; - if (first > last) - return; - - while (l <= r) - { - while (array[l] < pivot) - l++; - while (array[r] > pivot) - r--; - if (l <= r) - { - int smth = array[l]; - array[l] = array[r]; - array[r] = smth; - l++; - r--; - } - } - recurs(array, first, r); - recurs(array, l, last); -} -// -------------------------------------------------------------------------------- - -int main() -{ - int n; - scanf("%d", &n); - int array[n]; - int array2[n]; - for (int i = 0; i < n; i++) - { - scanf("%d", &array[i]); - } - for (int j = 0; j < n; ++j) - { - array2[j] = array[j]; - } - recurs(array, 0, n - 1); - sort(array2, n); - printf("slow "); - for (int i = 0; i < n; i++) - { - printf("%d ", array[i]); - } - printf("\n"); - printf("fast "); - for (int s = 0; s < n; s++) - { - printf("%d ", array2[s]); - } - return 0; -} diff --git a/task3/Shvetssova.c b/task3/Shvetssova.c index 7e3e606..ebb06ca 100644 --- a/task3/Shvetssova.c +++ b/task3/Shvetssova.c @@ -1,7 +1,11 @@ #include #include -void sort(int array[], int first, int last) +void sort(int array[], int size) { + sort1(array, 0, size); +} + +void sort1(int array[], int first, int last) { int l = first; @@ -38,7 +42,7 @@ int main() { scanf("%d", &array[i]); } - sort(array, 0, n); + sort(array, n); for (int i = 0; i < n; i++) { printf("%d ", array[i]); From e8f51d0f21229e6e85ab62289dc9278a856a4fd0 Mon Sep 17 00:00:00 2001 From: Ksunyy Date: Fri, 10 Nov 2023 14:28:49 +0300 Subject: [PATCH 10/11] Update --- task3/Shvetssova.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/task3/Shvetssova.c b/task3/Shvetssova.c index ebb06ca..b8ce47c 100644 --- a/task3/Shvetssova.c +++ b/task3/Shvetssova.c @@ -29,8 +29,8 @@ void sort1(int array[], int first, int last) r--; } } - sort(array, first, r); - sort(array, l, last); + sort1(array, first, r); + sort1(array, l, last); } int main() From 2504621497a3c4cfcd86968afda4613c6e73b618 Mon Sep 17 00:00:00 2001 From: Ksunyy Date: Fri, 10 Nov 2023 14:31:15 +0300 Subject: [PATCH 11/11] Fix --- task3/Shvetssova.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/task3/Shvetssova.c b/task3/Shvetssova.c index b8ce47c..b4c1179 100644 --- a/task3/Shvetssova.c +++ b/task3/Shvetssova.c @@ -2,7 +2,7 @@ #include void sort(int array[], int size) { - sort1(array, 0, size); + sort1(array, 0, size - 1); } void sort1(int array[], int first, int last)