Skip to content

Контрольная работа 1 - #9

Open
EStarikov wants to merge 1 commit into
mainfrom
control_1
Open

Контрольная работа 1#9
EStarikov wants to merge 1 commit into
mainfrom
control_1

Conversation

@EStarikov

Copy link
Copy Markdown
Owner

No description provided.

@EStarikov
EStarikov requested a review from chernishev October 17, 2025 14:16

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

За все задачи 9/10

Comment thread src/different_palindrom.c

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.

Вы добавили на HWProj только первую задачу, так что я смогу поставить баллы только за неё.

Comment thread src/different_palindrom.c
Comment on lines +5 to +10
while (a >= 2) {
b[index] = a % 2;
a = a / 2;
++index;
}
b[index] = a; // число будет записано задом наперед, но для палиндрома это не важно

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.

Здесь не нужно отдельно рассматривать a < 2. Можно сразу писать цикл до нуля.

Comment thread src/max_sum_num.c
Comment on lines +4 to +6
if (a < 0) {
a = a * -1;
}

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
if (a < 0) {
a = a * -1;
}
a = abs(a);

Comment thread src/max_sum_num.c
a = a * -1;
}
while (a / 10 != 0) {
s = s + (a % 10);

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
s = s + (a % 10);
s += (a % 10);

Comment thread src/max_sum_num.c
Comment on lines +7 to +9
while (a / 10 != 0) {
s = s + (a % 10);
a = a / 10;

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/monkey_sort.c
int check(int arr[], int n) {
for (int i = 1; i < n; ++i) {
if (arr[i] < arr[i - 1]) {
return 1;

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.

Конвенционально делается наоборот: 1 -- это true, а 0 -- false. Чтобы не было таких проблем, лучше использовать stdbool.h

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