Skip to content

Comments

Test2. Kalsina Yana.#14

Open
yaprogrammer18-yanchi wants to merge 5 commits intomainfrom
test2_branch
Open

Test2. Kalsina Yana.#14
yaprogrammer18-yanchi wants to merge 5 commits intomainfrom
test2_branch

Conversation

@yaprogrammer18-yanchi
Copy link
Owner

Добавила решение второй задачки из контрольной. Так же для нее прописан Cmake в самой папке со всеми файлами. Написаны тесты в отдельном файле, который соединяется с main.c с помощью хедера lib.h

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.

Никаких артефактов по первой задачке я вообще не нашел :(

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 +13 to +18
/*
функция перевода массива с булевыми элементами в целочисленные 0 и 1
на вход принимает указатель на массив и его длину
возвращает указатель на новый массив.
*/
int* convertBoolElementsToInt(bool* arr, 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.

Ненужная функция. При касте bool превращается в 0 и 1 соответственно, т.е. их bool можно использовать там, где ожидается int.

/* функция (собирающая все другие функции)
она сравнивает два числа
на вход пинимает два указателя на массивы с булевыми значениями
возвращает 1, -1, 0 в зависимости от результата сравнения.
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 +24 to +29
if (arr[i] == false) {
newArr[i] = 0;
} else {
newArr[i] = 1;
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

А что говорилось про смысл выражений типа true == true?

Comment on lines +37 to +40
int* newArr1 = convertBoolElementsToInt(p1, 8);
int decimal1 = convertToDecimal8bits(newArr1);
int* newArr2 = convertBoolElementsToInt(p2, 8);
int decimal2 = convertToDecimal8bits(newArr2);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Не-а. Сравнивать нужно было массивы bool.

}

// так как в условии ничего не сказано про длину масиива, пусть она будет всего 8 элементов (8 бит)
int main(int argc, char* argv[])
Copy link
Collaborator

Choose a reason for hiding this comment

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

Зачем такие сложности, если без флага --test Вы всё равно запускаете тест, просто всего один?

* функция перевода 8ми битного числа в десятичную систему счисления
* принимает на ход указатель на массив с целочисленными значениями 0 и 1
*/
int convertToDecimal8bits(int* binary);
Copy link
Collaborator

Choose a reason for hiding this comment

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

И, кстати, числа-то неотрицательные, почему тогда здесь везде int?

return decimal;
}

int* convertBoolElementsToInt(bool* arr, 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.

Если у Вас до этого функция работает только с 8битными числами, зачем здесь произвольная длина? (Или там тогда зачем ограничение?)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Здесь как-то грустненько :( Но код Вы написали и он даже как-то работает. 4 балла.

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