-
Notifications
You must be signed in to change notification settings - Fork 15
HOMEWORK 1 #11
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
base: main
Are you sure you want to change the base?
HOMEWORK 1 #11
Conversation
attempt 1
task_01/src/topology_sort.cpp
Outdated
@@ -1 +1,16 @@ | |||
#include "topology_sort.hpp" | |||
|
|||
std::tuple<bool, int *, int *> topology_sort(int *arr, int n, int m) { |
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.
имя функции не отображает что она делает, и не в том кодстайле (TopologySort)
task_01/src/topology_sort.cpp
Outdated
@@ -1 +1,16 @@ | |||
#include "topology_sort.hpp" | |||
|
|||
std::tuple<bool, int *, int *> topology_sort(int *arr, int n, int m) { | |||
int *b = arr, *e = arr + (n - 1); |
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.
b и e плохие названия переменных
task_01/src/topology_sort.cpp
Outdated
|
||
std::tuple<bool, int *, int *> topology_sort(int *arr, int n, int m) { | ||
int *b = arr, *e = arr + (n - 1); | ||
bool found = 1; |
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.
не 1 а true
task_01/src/topology_sort.cpp
Outdated
@@ -1 +1,16 @@ | |||
#include "topology_sort.hpp" | |||
|
|||
std::tuple<bool, int *, int *> SummanddsInArray(int *arr, int n, int sum) { | |||
int *begin = arr, *end = arr + (n - 1); |
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.
давай делать так: одна строка одно объявление
task_01/src/topology_sort.cpp
Outdated
begin++; | ||
if ((!begin) || (!end) || (begin >= end) || (*begin + *end != sum)) { | ||
begin = end = nullptr; | ||
found = 0; |
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.
found = true;
task_01/src/topology_sort.cpp
Outdated
@@ -1 +1,16 @@ | |||
#include "topology_sort.hpp" | |||
|
|||
std::tuple<bool, int *, int *> SummanddsInArray(int *arr, int n, int sum) { |
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.
сомнительный конечно тип возвращаемого значения, может тогда лучше std::optional?
task_01/src/topology_sort.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.
давай файл переименуем
attempt 4 |
int m = 11; | ||
std::optional<std::tuple<int*, int*>> a = SummanddsInArray(arr, n, m); | ||
ASSERT_TRUE(a); | ||
ASSERT_EQ(*std::get<0>(a.value()) + *std::get<1>(a.value()), m); |
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.
имхо так лучше выглядит: ASSERT_EQ(*a->first + *a->second, m);
task_01/src/summandds_in_array.hpp
Outdated
@@ -0,0 +1,9 @@ | |||
#ifndef TOPOLOGY_SORT_HPP | |||
#define TOPOLOGY_SORT_HPP |
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.
давай в соответствии с именем файла переименуем
now it's SUMMANDDS_IN_ARRAY_HPP
attempt 1