-
Notifications
You must be signed in to change notification settings - Fork 39
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
Тутынина Полина Ивановна #26
Conversation
src/main.cpp
Outdated
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.
Зачем удалили файл?
src/two-sum.cpp
Outdated
@@ -0,0 +1,29 @@ | |||
#define ARRAY_SIZE 5 |
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.
Можно было не дублировать определение макроса, а просто сделать #include "two-sum.hpp"
src/two-sum.cpp
Outdated
index1 = 0; | ||
for(int i = 0; i < ARRAY_SIZE-1; ++i) { | ||
for(int j = i+1; j < ARRAY_SIZE; ++j) { | ||
if ((nums[i]+nums[j] == target)&&(i!=j)) { |
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.
Условие i != j
всегда истинно, так как int j = i+1
src/two-sum.cpp
Outdated
{ | ||
index0 = 0; | ||
index1 = 0; | ||
for(int i = 0; i < ARRAY_SIZE-1; ++i) { |
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.
Для счетчиков циклов лучше использовать беззнаковые целочисленные типы
src/two-sum.cpp
Outdated
for(int i = 0; i < ARRAY_SIZE-1; ++i) { | ||
for(int j = i+1; j < ARRAY_SIZE; ++j) { | ||
if ((nums[i]+nums[j] == target)&&(i!=j)) { | ||
if (i<j) { |
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.
Условие i < j
всегда истинно
Задание принято |
No description provided.