Skip to content

Comments

Optimal sorting Kalsina Yana#5

Open
yaprogrammer18-yanchi wants to merge 15 commits intomainfrom
optimisated_sort_branch
Open

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

Conversation

@yaprogrammer18-yanchi
Copy link
Owner

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


int sort(int *list, int length) {

int *rememberList =
Copy link
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 =

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
Collaborator

Choose a reason for hiding this comment

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

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

#include "sort.h"
#include <stdlib.h>

int sort(int *list, int length) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

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


int main() {

int *onlyNumbersList = calloc(200, sizeof(int));
Copy link
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
Collaborator

Choose a reason for hiding this comment

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

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

{
onlyNumbersList[length++] = inputNumber; // добавляем число в список
}

Copy link
Collaborator

Choose a reason for hiding this comment

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

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

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
Collaborator

Choose a reason for hiding this comment

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

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


int main() {

int *ArrayWithNumbers = calloc(100, sizeof(int));
Copy link
Collaborator

Choose a reason for hiding this comment

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

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

} else {
return 1;
}
nextSymbol = getchar(); // читаем символ, который был введен дальше
Copy link
Collaborator

Choose a reason for hiding this comment

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

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

Comment on lines 9 to 11
for (int i = 0; i < length; i++) {
unsortedArray[i] = array[i];
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

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

Copy link
Collaborator

@WoWaster WoWaster left a comment

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
Copy link
Collaborator

@WoWaster WoWaster left a comment

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