Skip to content

Comments

ДЗ №6#13

Open
shknoko wants to merge 23 commits intomasterfrom
06_lists
Open

ДЗ №6#13
shknoko wants to merge 23 commits intomasterfrom
06_lists

Conversation

@shknoko
Copy link
Owner

@shknoko shknoko commented Dec 12, 2025

  • Balance of brackets checker
  • substring count
  • zero elements count
  • removed logic from main
  • Brackets checker
  • Removed logic from main
  • changed return type
  • removed pointers in functions
  • List implementation
  • Added printList, extended indexOf and isEmpty
  • Sorted list program
  • Rewrited with switch
  • Circular list implementation
  • Josephus problem
  • Fixed circularList.h
  • Fixed condition
  • Updated .gitignore
  • Fixed codestyle
  • Refactored sortedList
  • Refactored josephusProblem
  • Removed redundant condition
  • Added newline character in printf
  • Added CMakeLists

@shknoko shknoko self-assigned this Dec 12, 2025
@shknoko shknoko requested a review from WoWaster December 12, 2025 17:37
} else if (string[i] == ')') {
balance--;
if (balance < 0) {
result = false;

Choose a reason for hiding this comment

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

Мб стоило поставить break (true никогда не появится)

int n = 0;
scanf("%d\n", &n);

char* input = calloc(n + 1, sizeof(char));

Choose a reason for hiding this comment

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

Нет проверки (!input)

Comment on lines +38 to +40
bool result = true;

result = bracketsChecker(input);

Choose a reason for hiding this comment

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

Suggested change
bool result = true;
result = bracketsChecker(input);
bool result = bracketsChecker(input);

int counter = 0;
scanf("%d\n", &n);

int *array = malloc(n * sizeof(int));

Choose a reason for hiding this comment

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

  1. нет проверки (!array)
  2. почему не calloc

}

break;
case 3:

Choose a reason for hiding this comment

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

Стоит обернуть в enum

int indexOf(List* list, int data, unsigned* res)
{
if (list == NULL || res == NULL) {
return 2;

Choose a reason for hiding this comment

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

коды возврата лучше завернуть в define

Comment on lines +18 to +19
List* newList = calloc(1, sizeof(List));
return newList;

Choose a reason for hiding this comment

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

Suggested change
List* newList = calloc(1, sizeof(List));
return newList;
return calloc(1, sizeof(List));

int isEmpty(List* list)
{
if (list == NULL) {
return 2;

Choose a reason for hiding this comment

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

Почему isEmpty не true или false, а 2... (ну и как минимум в define бы)

return false;
}

List* list = newList();

Choose a reason for hiding this comment

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

нет проверки (!list)

int n = 0, m = 0;
scanf("%d%d", &n, &m);

int res = -1;

Choose a reason for hiding this comment

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

зачем выставлять в -1, если josephus()=true перезапишет res, а josephus()=false не дойдет до printf где используется res?

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