Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions srctwo-sum.cpp

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.

Файл назван srctwo-sum.cpp, а не two-sum.cpp. И находится в корневой директории проекта, а не в src/. Из-за этого не собираются тесты

Как поправить:

$ git mv srctwo-sum.cpp src/two-sum.cpp
$ git commit -m "moved file"
$ git push

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include "two-sum.hpp"

bool two_sum(
const int nums[ARRAY_SIZE],
const int target,
std::size_t& index0,
std::size_t& index1
)

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.

С самим кодом все хорошо, но надо соблюдать последовательность в стиле)

Между сигнатурой функции и телом обычно не ставят новую строку, пробелы в for между выражениями где-то поставлены, а где-то нет

Для домашнего задания в университете совсем не критично, но в реальных проектах обычно за этим следят


{
for(int i = 0; i < ARRAY_SIZE - 1;i++)
{
for(int j = i+1; j < ARRAY_SIZE; j++)
{
if(nums[i] + nums[j] == target)
{
index0 = i;
index1 = j;
return true;
}
}
}
return false;
};
Loading