Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
dad85a7
Update addition.cpp
vova22013 Nov 28, 2025
cd838e2
Update char_changer.cpp
vova22013 Nov 28, 2025
e0756b3
Update check_flags.cpp
vova22013 Nov 28, 2025
a2df496
Update length_lit.cpp
vova22013 Nov 28, 2025
77d65d3
Update print_bits.cpp
vova22013 Nov 28, 2025
13ced12
Update quadratic.cpp
vova22013 Nov 28, 2025
e1b9360
Update rms.cpp
vova22013 Nov 28, 2025
578ce8e
Merge branch 'psds-cpp:main' into main
vova22013 Dec 8, 2025
ca41a8c
add (solution): add func_array task, add last_of_us task, add little_…
vova22013 Dec 9, 2025
39e864a
add (solution): add swap_ptr task
vova22013 Dec 9, 2025
25212e4
Merge branch 'main' of github.com:psds-cpp/psds-cpp-2025
vova22013 Dec 14, 2025
e51b15d
Merge branch 'main' of github.com:psds-cpp/psds-cpp-2025
vova22013 Dec 16, 2025
78eedfd
add (solution): add daata_stats task
vova22013 Dec 17, 2025
abd3695
add (solution): add easy_compare task
vova22013 Dec 17, 2025
bcdbc84
add (solution): add enum_operators task
vova22013 Dec 17, 2025
cd158cf
add (solution): add filter task
vova22013 Dec 17, 2025
a2130ad
add (solution): add find_all task
vova22013 Dec 17, 2025
4a8e567
add (solution): add minmax task
vova22013 Dec 17, 2025
8de38a3
add (solution): add os_overload task
vova22013 Dec 17, 2025
fd46bb9
add (solution): add range task
vova22013 Dec 17, 2025
685908d
add (solution): add unique task
vova22013 Dec 17, 2025
099cfcf
Delete 04_week directory
vova22013 Dec 17, 2025
b88738d
add (fix): add easy_compare task
vova22013 Dec 17, 2025
5c96344
Merge branch 'main' of github.com:vova22013/psds-cpp-2025
vova22013 Dec 17, 2025
dcf12db
Merge branch 'main' of github.com:psds-cpp/psds-cpp-2025
vova22013 Dec 23, 2025
c0bf6d8
add (solution): add phasor task
vova22013 Dec 26, 2025
4bedb7e
add (solution): add queue task
vova22013 Dec 26, 2025
8392551
add (solution): add ring_buffer task
vova22013 Dec 26, 2025
96da6a7
add (solution): add stack task
vova22013 Dec 26, 2025
ec1437a
fix error
vova22013 Feb 10, 2026
13d548b
fix errors
vova22013 Feb 10, 2026
a2a8659
fix errors
vova22013 Feb 10, 2026
658d756
fix errors
vova22013 Feb 10, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions 01_week/tasks/addition/addition.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include <cstdint>
#include <stdexcept>


int64_t Addition(int a, int b) {
throw std::runtime_error{"Not implemented"};
}
return static_cast<int64_t>(a) + b;
}
60 changes: 59 additions & 1 deletion 01_week/tasks/char_changer/char_changer.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,65 @@
#include <cstddef>
#include <stdexcept>
#include <cctype>

const char dif_letters = 'a' - 'A';

size_t CharChanger(char array[], size_t size, char delimiter = ' ') {
throw std::runtime_error{"Not implemented"};
size_t count = 1, last_ind = size - 1;
size_t start_rep_ind, end_rep_ind;

for (size_t i = 0; i < size; ++i) {
if (i == size - 1) {
return last_ind;
}

if (array[i] == array[i + 1]) {
if (count == 1) start_rep_ind = i;
count++;

if (array[i] == ' ') continue;
}
else if (count != 1) {
end_rep_ind = i + 1;
i = start_rep_ind;

size_t ind_next_simbol = i + 2;
last_ind -= count - 2;

if (array[i] != ' ') {
if (count >= 10) array[++i] = '0';
else array[++i] = static_cast<char>(static_cast<size_t>('0') + count);
}
else {
--ind_next_simbol;
--last_ind;
array[i] = delimiter;
}

for (size_t j = end_rep_ind; j < size; ++j) {
std::swap(array[ind_next_simbol], array[j]);
++ind_next_simbol;
}

size_t reduct_size = end_rep_ind - start_rep_ind;
size -= reduct_size - 2;
count = 1;
continue;
}

if (std::isdigit(array[i])) {
array[i] = '*';
}
else if (std::islower(array[i])) {
array[i] -= dif_letters;
}
else if (std::ispunct(array[i])) {
array[i] = '_';
}
else if (std::isspace(array[i])) {
array[i] = delimiter;
}
}

return last_ind;
}
52 changes: 51 additions & 1 deletion 01_week/tasks/check_flags/check_flags.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <cstdint>
#include <stdexcept>
#include <iostream>


enum class CheckFlags : uint8_t {
Expand All @@ -14,5 +15,54 @@ enum class CheckFlags : uint8_t {
};

void PrintCheckFlags(CheckFlags flags) {
throw std::runtime_error{"Not implemented"};
if (flags > CheckFlags::ALL) {
std::cout << "";
return;
}

bool the_first = true;
std::string str_flags = "[";

size_t max_value_flag = 32;
for (size_t i = 0; i < max_value_flag; i >>= 1) {
auto b_i = static_cast<uint8_t>(flags) >> i & 1u;
if (b_i) {


}
}

if (static_cast<uint8_t>(flags) &
static_cast<uint8_t>(CheckFlags::TIME)) {
str_flags += "TIME";
the_first = false;
}
if (static_cast<uint8_t>(flags) &
static_cast<uint8_t>(CheckFlags::DATE)) {
the_first ? str_flags += "DATE" : str_flags += ",DATE";
Copy link
Contributor

Choose a reason for hiding this comment

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

дублируется DATE

the_first = false;
}
if (static_cast<int8_t>(flags) &
static_cast<int8_t>(CheckFlags::USER) ) {
the_first ? str_flags += "USER" : str_flags += ",USER";
the_first = false;
}
if (static_cast<int8_t>(flags) &
static_cast<int8_t>(CheckFlags::CERT)) {
the_first ? str_flags += "CERT" : str_flags += ",CERT";
the_first = false;
}
if (static_cast<int8_t>(flags) &
static_cast<int8_t>(CheckFlags::KEYS)) {
the_first ? str_flags += "KEYS" : str_flags += ",KEYS";
the_first = false;
}
if (static_cast<int8_t>(flags) &
static_cast<int8_t>(CheckFlags::DEST)) {
the_first ? str_flags += "DEST" : str_flags += ",DEST";
the_first = false;
}
Copy link
Contributor

@18thday 18thday Jan 20, 2026

Choose a reason for hiding this comment

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

много дублирования кода, можно код построить более оптимально без дублирвоания


str_flags += "]";
std::cout << str_flags;
}
65 changes: 65 additions & 0 deletions 01_week/tasks/length_lit/length_lit.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
namespace {
const double m_in_inch = 0.0254;
const double m_in_foot = 0.3048;
const double m_in_cm = 0.01;
}


// m
constexpr long double operator""_m_to_m(long double m) {
return m;
}
constexpr long double operator""_m_to_in(long double m) {
return m / m_in_inch;
}
constexpr long double operator""_m_to_ft(long double m) {
return m / m_in_foot;
}
constexpr long double operator""_m_to_cm(long double m) {
return m / m_in_cm;
}


// cm
constexpr long double operator""_cm_to_cm(long double cm) {
return cm;
}
constexpr long double operator""_cm_to_in(long double cm) {
return cm / (m_in_inch / m_in_cm);
}
constexpr long double operator""_cm_to_ft(long double cm) {
return cm / (m_in_foot / m_in_cm);
}
constexpr long double operator""_cm_to_m(long double cm) {
return cm / m_in_cm;
}


// foot
constexpr long double operator""_ft_to_ft(long double ft) {
return ft;
}
constexpr long double operator""_ft_to_in(long double ft) {
return ft * (m_in_foot / m_in_inch);
}
constexpr long double operator""_ft_to_m(long double ft) {
return ft * m_in_foot;
}
constexpr long double operator""_ft_to_cm(long double ft) {
return ft * (m_in_foot / m_in_cm);
}


// inch
constexpr long double operator""_in_to_in(long double in) {
return in;
}
constexpr long double operator""_in_to_ft(long double in) {
return in * (m_in_inch / m_in_foot);
}
constexpr long double operator""_in_to_m(long double in) {
return in * m_in_inch;
}
constexpr long double operator""_in_to_cm(long double in) {
return in * (m_in_inch / m_in_cm);
}
18 changes: 14 additions & 4 deletions 01_week/tasks/print_bits/print_bits.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
#include <cstddef>
#include <stdexcept>

#include <iostream>
#include <algorithm>

void PrintBits(long long value, size_t bytes) {
throw std::runtime_error{"Not implemented"};
auto count_bits = bytes * 8;
std::string str_bset = "0b";

for (size_t i = count_bits; i > 0; --i) {
auto b_i = (value >> (i - 1)) & 1u;
b_i ? str_bset += "1" : str_bset += "0";

if ((i - 1) % 4 == 0 && i != count_bits && i != 1) {
str_bset += '\'';
}
}
std::cout << str_bset << "\n";
}
68 changes: 65 additions & 3 deletions 01_week/tasks/quadratic/quadratic.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,68 @@
#include <stdexcept>

#include <iomanip>
#include <iostream>
#include <string>
#include <cmath>

void SolveQuadratic(int a, int b, int c) {
throw std::runtime_error{"Not implemented"};
}
double x_1, x_2;
bool a_is_zero = a == 0;
bool b_is_zero = b == 0;
bool c_is_zero = c == 0;

std::cout << std::setprecision(6);

if (a_is_zero && b_is_zero && c_is_zero) {
std::cout << "infinite solutions";
return;
} else if (a_is_zero && b_is_zero && !c_is_zero) {
std::cout << "no solutions";
return;
} else if (a_is_zero && !b_is_zero && c_is_zero) {
std::cout << c;
return;
} else if (a_is_zero && !b_is_zero && !c_is_zero) {
x_1 = static_cast<double>(-c) / static_cast<double>(b);
std::cout << x_1;
return;
} else if (!a_is_zero && b_is_zero && c_is_zero) {
std::cout << "0";
return;
} else if (!a_is_zero && b_is_zero && !c_is_zero) {
if (a * c > 0) {
std::cout << "no solutions";
return;
}
x_2 = std::sqrt(static_cast<double>(-c) / static_cast<double>(a));
x_1 = -x_2;
std::cout << x_1 << " " << x_2;
return;
} else if (!a_is_zero && !b_is_zero && c_is_zero) {
x_1 = 0.;
x_2 = static_cast<double>(-b) / a;
if (x_1 > x_2) std::swap(x_1, x_2);
std::cout << x_1 << " " << x_2;
return;
}

double D_2 = b * b - 4.0 * a * c;
double eps = 1e-14;

if (D_2 < 0) {
std::cout << "no solutions";
return;
}
else if (D_2 < eps) {
x_1 = static_cast<double>(-b) / (2 * a);
std::cout << x_1;
return;
}
else {
double D = std::sqrt(D_2);
x_1 = (-b + D) / (2 * a);
x_2 = (-b - D) / (2 * a);
if (x_1 > x_2) std::swap(x_1, x_2);
std::cout << x_1 << " " << x_2;
return;
}
}
14 changes: 9 additions & 5 deletions 01_week/tasks/rms/rms.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
#include <cstdef>
#include <stdexcept>

#include <cstddef>
#include <cmath>

double CalculateRMS(double values[], size_t size) {
throw std::runtime_error{"Not implemented"};
}
if (values == nullptr || size == 0) return static_cast<double>(0.0);
double sum = 0.0;
for (size_t i = 0; i < size; ++i) {
sum += values[i] * values[i];
}
return std::sqrt(sum / size);
}
10 changes: 8 additions & 2 deletions 02_week/tasks/func_array/func_array.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#include <stdexcept>


double ApplyOperations(double a, double b /* other arguments */) {
throw std::runtime_error{"Not implemented"};
double ApplyOperations(const double a, const double b,
double (*operations[])(const double, const double), size_t countOperations)
{
double res = 0.0;
for (size_t i = 0; i < countOperations; ++i){
if (operations[i] != nullptr) res += operations[i](a, b);
}
return res;
}
12 changes: 10 additions & 2 deletions 02_week/tasks/last_of_us/last_of_us.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
#include <stdexcept>

const int* FindLastElement(const int* begin, const int* end,
bool(*predicate)(int)) {

if (!predicate || !begin || !end || std::distance(begin, end) < 0)
return end;

for(const int* it = end - 1; it != begin - 1; --it) {
if (predicate(*it)) return it;
}

/* return_type */ FindLastElement(/* ptr_type */ begin, /* ptr_type */ end, /* func_type */ predicate) {
throw std::runtime_error{"Not implemented"};
return end;
}
Loading