Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 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
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
7 changes: 4 additions & 3 deletions 01_week/tasks/addition/addition.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#include <cstdint>
#include <stdexcept>


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

const char a = 'a';
const char A = 'A';
const char dif_letters = static_cast<int>(a) - static_cast<int>(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 (static_cast<bool>(std::isdigit(array[i]))) {
array[i] = '*';
}
else if (static_cast<bool>(std::islower(array[i]))) {
array[i] -= dif_letters;
}
else if (static_cast<bool>(std::ispunct(array[i]))) {
array[i] = '_';
}
else if (static_cast<bool>(std::isspace(array[i]))) {
array[i] = delimiter;
}
}

return last_ind;
}
43 changes: 42 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,45 @@ 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 = "[";

if (static_cast<int8_t>(flags) &
static_cast<int8_t>(CheckFlags::TIME)) {
str_flags += "TIME";
the_first = false;
}
if (static_cast<int8_t>(flags) &
static_cast<int8_t>(CheckFlags::DATE)) {
the_first ? str_flags += "DATE" : str_flags += ",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;
}

str_flags += "]";
std::cout << str_flags;
}
68 changes: 68 additions & 0 deletions 01_week/tasks/length_lit/length_lit.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
constexpr long double operator""_m_to_in(long double m) {
return m / 0.0254;
}

constexpr long double operator""_m_to_ft(long double m) {
return m / 0.3048;
}

constexpr long double operator""_m_to_m(long double m) {
return m;
}

constexpr long double operator""_m_to_cm(long double m) {
return m * 100;
}

// foots
constexpr long double operator""_ft_to_in(long double ft) {
return ft * (0.3048 / 0.0254);
}

constexpr long double operator""_ft_to_ft(long double ft) {
return ft;
}

constexpr long double operator""_ft_to_m(long double ft) {
return ft * 0.3048;
}

constexpr long double operator""_ft_to_cm(long double ft) {
return ft * 30.48;
}


// 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 * (0.0254 / 0.3048);
}

constexpr long double operator""_in_to_m(long double in) {
return in * 0.0254;
}

constexpr long double operator""_in_to_cm(long double in) {
return in * 2.54;
}


// cm
constexpr long double operator""_cm_to_in(long double cm) {
return cm / 2.54;
}

constexpr long double operator""_cm_to_ft(long double cm) {
return cm / 30.48;
}

constexpr long double operator""_cm_to_m(long double cm) {
return cm / 100;
}

constexpr long double operator""_cm_to_cm(long double cm) {
return cm;
}
26 changes: 22 additions & 4 deletions 01_week/tasks/print_bits/print_bits.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
#include <cstddef>
#include <stdexcept>

#include <iostream>
#include <algorithm>

void PrintBits(long long value, size_t bytes) {
throw std::runtime_error{"Not implemented"};
std::string str_bset = "";

auto bits = bytes * 8;

for (size_t i = 0; i < bits; ++i) {
auto b_i = (value >> i) & 1u;

if (static_cast<bool>(b_i)) str_bset += "1";
else str_bset += "0";

if (i % 4 == 3 && i != bits - 1) {
str_bset += '\'';
}
}

str_bset += "b0";

std::reverse(str_bset.begin(), str_bset.end());

std::cout << str_bset << "\n";
}
91 changes: 88 additions & 3 deletions 01_week/tasks/quadratic/quadratic.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,91 @@
#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 ? true : false);
bool b_is_Zero = (b == 0 ? true : false);
bool c_is_Zero = (c == 0 ? true : false);

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

if (a_is_Zero) {
if (b_is_Zero) {
if (c_is_Zero) {
std::cout << "infinite solutions";
}
else {
std::cout << "no solutions";
}
}
else {
if (c_is_Zero){
std::cout << c;
}
else{
x_1 = static_cast<double>(-c) / static_cast<double>(b);
std::cout << x_1;
}
}

return;
}
else {
if (b_is_Zero){
if (c_is_Zero) {
std::cout << c;
}
else {
if (a * c < 0) {
x_1 = std::sqrt(static_cast<double>(-c) / static_cast<double>(a));
x_2 = -x_1;

if (x_1 > x_2) std::swap(x_1, x_2);

std::cout << x_1 << " " << x_2;
}
else std::cout << "no solutions";
}
return;
}
else if (c_is_Zero) {
x_1 = static_cast<double>(0);
x_2 = static_cast<double>(-b) / static_cast<double>(a);

if (x_1 > x_2) std::swap(x_1, x_2);

std::cout << x_1 << " " << x_2;

return;
}
}

double b_d = static_cast<double>(b);
double a_d = static_cast<double>(a);
double c_d = static_cast<double>(c);

double D_2 = b_d * b_d - 4 * a_d * c_d;
double eps = 1e-14;

if (D_2 < 0) {
std::cout << "no solutions";
return;
}
else if (D_2 < eps) {
x_1 = -b_d / (2 * a_d);
std::cout << x_1;
}
else {
double D = static_cast<double>(std::sqrt(D_2));

x_1 = (-b_d + D) / (2 * a_d);
x_2 = (-b_d - D) / (2 * a_d);

if (x_1 > x_2) std::swap(x_1, x_2);

std::cout << x_1 << " " << x_2;
}
}
20 changes: 15 additions & 5 deletions 01_week/tasks/rms/rms.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
#include <cstdef>
#include <stdexcept>

#include <cstddef>
#include <cmath>

double CalculateRMS(double values[], size_t size) {
throw std::runtime_error{"Not implemented"};
}

if (values == NULL) return static_cast<double>(0.0);

if (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 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(double a, double b,
double (**operations)(double, 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;
}
16 changes: 13 additions & 3 deletions 02_week/tasks/last_of_us/last_of_us.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
#include <stdexcept>


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

if (predicate == nullptr ||
begin == nullptr ||
end == nullptr ||
std::distance(begin, end) < 0)
return const_cast<int*>(end);

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

return const_cast<int*>(end);
}
Loading