Skip to content

Sorted station. Kalsina Yana#8

Open
yaprogrammer18-yanchi wants to merge 17 commits into
mainfrom
sorted_station_branch
Open

Sorted station. Kalsina Yana#8
yaprogrammer18-yanchi wants to merge 17 commits into
mainfrom
sorted_station_branch

Conversation

@yaprogrammer18-yanchi

Copy link
Copy Markdown
Owner

Добавила файл к домашней работе "Сортировочная станция". Здесь три файла:
файл с решением задачи
файл с реализацией стека
файл с объявлениями структур и функций стека
последние два файла изначально были созданы на ветке стека.
P.S. Это еще одна, другая, ветка, исходящая от ветки стека.

Comment thread src/SortingStation/sortingStation.c Outdated
Comment thread src/SortingStation/sortingStation.c Outdated
Comment thread src/SortingStation/sortingStation.c Outdated
Comment thread src/SortingStation/stack.h
Comment thread src/SortingStation/sortingStation.c Outdated
Comment thread src/SortingStation/sortingStation.c Outdated
Comment thread src/SortingStation/sortingStation.c Outdated

@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.

Я правда обнаружил, что у Вас нет ветки со стеком, но уже деваться некуда :(


deleteStack(stack);
// чтобы строка была корректной
queue[queueEndPtr] = '\0';

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.

Хорошо бы ещё realloc здесь сделать

Comment thread src/SortingStation/sortingStation.c Outdated
Comment on lines +93 to +99
int queueLength = strlen(queue);
for (unsigned i = 0; i <= queueLength; i++) {
printf("%c", queue[i]);
if (i == strlen(queue)) {
printf("\n");
}
}

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 queueLength = strlen(queue);
for (unsigned i = 0; i <= queueLength; i++) {
printf("%c", queue[i]);
if (i == strlen(queue)) {
printf("\n");
}
}
printf("%s\n", queue);

?

char* convertString(char* string, int len)
{
struct Stack* stack = newStack();
char* queue = malloc(1000 * sizeof(char));

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/SortingStation/sortingStation.c Outdated
return 0;
}

char* convertString(char* string, int len)

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.

А почему длину строки нельзя посчитать прямо внутри функции?

queue[queueEndPtr] = '\0';
char* queue_realloced = realloc(queue, sizeof(char) * (strlen(queue) + 1));
free(stack);
return queue_realloced;

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.

Давайте я сделаю вид, что я не видел, что Вы накосячили с неймингом.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

господи, простите.... Чего-то я с питона не переключилась...

Comment thread .gitignore

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