Skip to content

Commit

Permalink
Add function to find closest numbers to a given value
Browse files Browse the repository at this point in the history
- Implement `find_closest_numbers` function to find the closest `n` numbers to a given value `x` in a sorted vector.
- Add test cases in `main` to validate the function with different inputs.
- Include debug output to display the input vector and the result for each test case.
  • Loading branch information
spikovich committed Oct 29, 2024
1 parent 9335772 commit 634f7d6
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 2 deletions.
8 changes: 8 additions & 0 deletions cpp/.idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions cpp/.idea/cpp.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions cpp/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions cpp/.idea/rust.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions cpp/.idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions cpp/custom_search_closest_Ns_to_some_X.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ std::vector<int> find_closest_numbers(const std::vector<int>& numbers, int x, in


std::cout << "\n------------------------------------------------\n";
std::cout << "Исходные числа:";
std::cout << "first:";
for (auto k : numbers) {
std::cout << " " << k;
}
std::cout << "\nНайденные числа для " << x << " :";
std::cout << "\nfind num " << x << " :";
for (auto k : res) {
std::cout << " " << k;
}
Expand Down

0 comments on commit 634f7d6

Please sign in to comment.