Skip to content

Comments

Sorted station. Kalsina Yana#8

Open
yaprogrammer18-yanchi wants to merge 17 commits intomainfrom
sorted_station_branch
Open

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

Conversation

@yaprogrammer18-yanchi
Copy link
Owner

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

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.

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


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

Choose a reason for hiding this comment

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

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

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

Choose a reason for hiding this comment

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

Тут память утекает

return 0;
}

char* convertString(char* string, int len)
Copy link
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
Collaborator

Choose a reason for hiding this comment

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

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

Copy link
Owner Author

Choose a reason for hiding this comment

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

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

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