Skip to content
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

Closed
wants to merge 3 commits into from

Conversation

Polina785643
Copy link

No description provided.

src/main.cpp Outdated
Copy link
Owner

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
Copy link
Owner

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)) {
Copy link
Owner

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) {
Copy link
Owner

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) {
Copy link
Owner

Choose a reason for hiding this comment

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

Условие i < j всегда истинно

@czertyaka
Copy link
Owner

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

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