🗑️」 clean: cleanup things and slightly improved ex02/main.cpp

This commit is contained in:
y-syo
2025-09-01 16:00:41 +02:00
parent 7b47994ddd
commit f9c38cfe86
6 changed files with 37 additions and 28 deletions

View File

@@ -11,27 +11,7 @@
#include <ctime>
#include <deque>
std::vector<size_t> generateJacobsthal(size_t n)
{
std::vector<size_t> seq;
if (n == 0)
return seq;
seq.push_back(0);
if (n == 1)
return seq;
seq.push_back(1);
size_t j0 = 0, j1 = 1;
while (true)
{
size_t jn = j1 + 2 * j0;
if (jn >= n)
break;
seq.push_back(jn);
j0 = j1;
j1 = jn;
}
return seq;
}
std::vector<size_t> generateJacobsthal(size_t n);
template <typename Container, typename T>
typename Container::iterator binaryInsertPosition(Container &c, const T &value)
@@ -41,7 +21,7 @@ typename Container::iterator binaryInsertPosition(Container &c, const T &value)
while (first < last)
{
typename Container::iterator mid = first + (last - first) / 2; //tzvetan told me a better way iirc but i don't remember D:
typename Container::iterator mid = first + (last - first) / 2;
if (*mid < value)
first = mid + 1;
else