Skip to content

Optimal sorting Kalsina Yana#5

Open
yaprogrammer18-yanchi wants to merge 15 commits into
mainfrom
optimisated_sort_branch
Open

Optimal sorting Kalsina Yana#5
yaprogrammer18-yanchi wants to merge 15 commits into
mainfrom
optimisated_sort_branch

Conversation

@yaprogrammer18-yanchi

Copy link
Copy Markdown
Owner

В папке optimalSortingDir разместила все файлы для сборки приложения. Сортировку писала пузырьком, реализацию сортировки оптимизировала с помощью О2.

Comment thread src/optimalSortingDir/sort.h
Comment thread src/optimalSortingDir/sort.c Outdated

int sort(int *list, int length) {

int *rememberList =

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
int *rememberList =
int *unsortedList =

Comment thread src/optimalSortingDir/sort.c Outdated
for (int i = 0; i < length; i++) {
for (int j = 0; j < length - 1 - i; j++) {
if (list[j] > list[j + 1]) {
int helpingVar = list[j];

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tmp было достаточно

Comment thread src/optimalSortingDir/sort.c Outdated
#include "sort.h"
#include <stdlib.h>

int sort(int *list, int length) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Как-то у Вас расположение звёздочек между файлами гуляет.

Comment thread src/optimalSortingDir/main.c Outdated

int main() {

int *onlyNumbersList = calloc(200, sizeof(int));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Зачем 200, если разговор был про 100 в задаче?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Название тоже странное

Comment thread src/optimalSortingDir/README.md
Comment thread src/optimalSortingDir/main.c
Comment thread src/optimalSortingDir/main.c Outdated
{
onlyNumbersList[length++] = inputNumber; // добавляем число в список
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Странная пустая строка

Comment thread src/optimalSortingDir/sort.c Outdated
Comment on lines +6 to +11
int *unsortedArray =
calloc(length, sizeof(int)); // c помощью этого списка будем счиатать
// элементы, изменившие свою позицию
for (int i = 0; i < length; i++) {
unsortedArray[i] = array[i];
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Пишите комментарии над сущностью, а не под ней или за ней.

Comment thread src/optimalSortingDir/main.c Outdated

int main() {

int *ArrayWithNumbers = calloc(100, sizeof(int));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тут надо с маленькой буквы

Comment thread src/optimalSortingDir/main.c Outdated
} else {
return 1;
}
nextSymbol = getchar(); // читаем символ, который был введен дальше

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

По условию требовали использовать только scanf().

Comment thread src/optimalSortingDir/sort.c Outdated
Comment on lines +9 to +11
for (int i = 0; i < length; i++) {
unsortedArray[i] = array[i];
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Это можно заменить на memcpy

@WoWaster WoWaster left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Я не понял, как я не заметил этого в прошлый раз, но тут явно беды с форматированием (2 пробела вместе 4, скобочки у функций должны быть на новой строке).

Проверьте, пожалуйста, что Вы запускаете clang-format из директории, где явно лежит файл .clang-format с настройками для WebKit (смотреть через ls -a, потому что по умолчанию его может быть не видно).

WoWaster
WoWaster previously approved these changes Dec 16, 2025

@WoWaster WoWaster left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ура!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants