-
Notifications
You must be signed in to change notification settings - Fork 49
Глотов Н.С ЛР№1 Cортировка Хоара с простым слиянием #160
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
NFELIV
wants to merge
9
commits into
valentina-kustikova:master
Choose a base branch
from
NFELIV:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
0a2bf30
Add files via upload
NFELIV e6f23f8
Исправил замечания
NFELIV 9878b3e
Add files via upload
NFELIV a651faf
ne tyda
NFELIV 930c174
Исправил замечания
NFELIV 4e87b86
Исправил замечания
NFELIV f802c08
Merge pull request #5 from NFELIV/NFELIV-patch1
NFELIV 01563a1
ne tyda
NFELIV e2cab15
отчет за 2 семестр
NFELIV File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| // №13 Сортировка Хоара с простым слиянием | ||
| // ЛР#1 Последовательная реализация | ||
|
|
||
| #include "stdafx.h" | ||
| #include <iostream> | ||
| #include <stdlib.h> | ||
| #include <omp.h> | ||
| #include <ctime> | ||
|
|
||
| using namespace std; | ||
|
|
||
| void CreateArray(double arr[], int lenght) //Генерация | ||
| { | ||
| srand((unsigned int)time(NULL)); | ||
| for (int i = 0; i < lenght; i++) | ||
| { | ||
| arr[i] = rand() % 10; | ||
| } | ||
| } | ||
|
|
||
| void PrintArray(double* arr, int size) //Печать | ||
| { | ||
| if (size < 20) | ||
| { | ||
| for (int i = 0; i < size; i++) | ||
| { | ||
| cout << arr[i]<< " "; | ||
| } | ||
| } | ||
| return; | ||
| } | ||
|
|
||
| void QuickSort(double* arr, int l, int r) //Сортировка | ||
| { | ||
| int i = l, j = r; | ||
| double m = arr[(r + l) / 2]; | ||
| double temp = 0; | ||
| while (i <= j) | ||
| { | ||
| while (arr[i] < m) | ||
| { | ||
| i++; | ||
| } | ||
| while (arr[j] > m) | ||
| { | ||
| j--; | ||
| } | ||
| if (i <= j) | ||
| { | ||
| if (i < j) | ||
| { | ||
| temp = arr[i]; | ||
| arr[i] = arr[j]; | ||
| arr[j] = temp; | ||
| } | ||
| i++; | ||
| j--; | ||
| } | ||
| } | ||
| if (j > l) | ||
| { | ||
| QuickSort(arr, l, j); | ||
| } | ||
| if (r > i) | ||
| { | ||
| QuickSort(arr, i, r); | ||
| } | ||
| } | ||
|
|
||
| int main(int argc, char * argv[]) | ||
| { | ||
| double size; | ||
| double array[100000]; | ||
| double time = 0; | ||
| cout << "Enter num's element's in array: "; | ||
| cin >> size; | ||
| CreateArray(array, size); | ||
| cout << "The Generated array: "; | ||
| PrintArray(array, size); | ||
| cout << endl; | ||
| time = clock(); | ||
| QuickSort(array, 0, size - 1); | ||
| time = (clock() - time) / static_cast<double>(CLOCKS_PER_SEC); | ||
| cout << "Array after QuickSort: "; | ||
| PrintArray(array, size); | ||
| cout << endl; | ||
| cout << "Sequence version time: " << time << endl; | ||
| delete[] array; | ||
| return 0; | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Массив должен создаваться динамически, количество элементов массива должно передаваться через аргументы командной строки.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alvls исправил замечания