Skip to content

Conversation

@PaninMaxim
Copy link

No description provided.

@PaninMaxim PaninMaxim changed the title Панин Максим 3HW Панин Максим Dec 1, 2024
src/two-sum.cpp Outdated
@@ -0,0 +1,39 @@
#include <iostream>
#define ARRAY_SIZE 5
Copy link
Collaborator

Choose a reason for hiding this comment

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

Можно подключить заголовочный файл two-sum.hpp и не дублировать определение макроса

src/two-sum.cpp Outdated
@@ -0,0 +1,39 @@
#include <iostream>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Заголовочный файл не используется

src/two-sum.cpp Outdated
std::size_t& index1
)
{
unsigned int kolvo_par = 0;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Зачем считаете количество пар? По условию задачи подойдет любая пара

src/two-sum.cpp Outdated
bool proverka_par = false;
for (unsigned int i = 0; i <= ARRAY_SIZE - 1; i++)
{
for (unsigned int j = i + 1; j <= ARRAY_SIZE; j++)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Условие должно быть < ARRAY_SIZE. Сейчас имеем выход за границы массива, что показывают тесты

src/two-sum.cpp Outdated
{
for (unsigned int i = 0; i < ARRAY_SIZE; i++)
{
for (unsigned int j = i + 1; j <= ARRAY_SIZE; j++)
Copy link
Collaborator

Choose a reason for hiding this comment

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

В этой строке все еще условие неверно

Если я всё правильно понял, то ошибка в том что я забыл что счёт идёт с 0, и до 5(ARRAY_SIZE) будет всего 6 чисел, а не 5, как должно быть
@czertyaka
Copy link
Collaborator

Задание принято

@czertyaka czertyaka closed this Dec 18, 2024
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