- 
                Notifications
    You must be signed in to change notification settings 
- Fork 0
Binary representation #10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
В PR не должно быть изменений в файлах, не связанных с задачей.
|  | ||
| #define SIZE sizeof(int) * 8 | ||
|  | ||
| int decimalToBinary(int number, int answer[]); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
лучше хранить биты в char
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Принято передавать массив в функцию по указателю
| if (!test()) | ||
| { | ||
| printf("Похоже, что сейчас программа не работает корректно"); | ||
| return 1; | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
коды ошибок и возврата выносим в define
| int exp = 2; | ||
| for (int i = 0; i < SIZE; ++i) | ||
| { | ||
| exp = exp * 2; | ||
| } | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exp не используется
| int elementsScanned1 = scanf("%d", &number1); | ||
| if (elementsScanned1 != 1) | ||
| { | ||
| printf("Похоже, что-то пошло не так\n"); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Похоже, что-то пошло не так\n" нужно вынести в константу
| if (!(test1 == binaryToDecimal(binary1)) * (test2 == binaryToDecimal(binary2)) * (test3 == binaryToDecimal(binary3)) * (test4 == binaryToDecimal(binary4))) | ||
| { | ||
| return false; | ||
| } | ||
|  | ||
| return true; | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
убрать if, нормально написать конъюнкцию через &&
| if (!(test1 * test2 * test3)) | ||
| { | ||
| return false; | ||
| } | ||
|  | ||
| return true; | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
убрать if, нормально написать конъюнкцию через &&
| return true; | ||
| } | ||
|  | ||
| bool testStarterAddition(int a, int b, int answer) | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
testCaseAddition
| if (decimalAnswer != answer) | ||
| { | ||
| return false; | ||
| } | ||
|  | ||
| return true; | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
убрать if
| } | ||
|  | ||
| return true; | ||
| } No newline at end of file | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Перенос строки в конце файла
No description provided.