Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
31ce710
Тестовый коммит. Addition
RIZONTE Nov 24, 2025
f299b48
add solution: add addition task
RIZONTE Nov 24, 2025
b31a9d1
add (github): add testing action
RIZONTE Nov 24, 2025
643d325
fix (solution): Ошибка в директиве include
RIZONTE Nov 24, 2025
9744f6e
Merge branch 'main' of github.com:RIZONTE/psds-cpp-2025
RIZONTE Nov 24, 2025
48d2baf
add (solution): Решены задачи rms и char_changer
RIZONTE Nov 27, 2025
be553da
Merge branch 'main' of https://github.com/psds-cpp/psds-cpp-2025
RIZONTE Nov 27, 2025
852bf3a
add (solution): Решение Check_flags
RIZONTE Nov 28, 2025
d704a5e
modify (solution): Добавил комментарии в check_flags.cpp
RIZONTE Nov 28, 2025
4ef2338
add (solution): Добавлено решение length_lit
RIZONTE Nov 28, 2025
afc1d22
add (solution): Решение print_bits
RIZONTE Nov 28, 2025
2b41f11
add (solution): Решение quadratic
RIZONTE Nov 28, 2025
af33200
Merge branch 'main' of https://github.com/psds-cpp/psds-cpp-2025
RIZONTE Dec 5, 2025
5eddea2
add (solution): Решение func_array
RIZONTE Dec 5, 2025
be140db
add (solution): Решение last_of_us
RIZONTE Dec 5, 2025
d57c94c
add (solution): Решение little_big
RIZONTE Dec 6, 2025
0e3b4bf
add (solution): Решение longest
RIZONTE Dec 6, 2025
6779b17
modify (solution): Добавил константность итератору в for
RIZONTE Dec 6, 2025
e61c5b9
add (solution): Решение pretty_array
RIZONTE Dec 6, 2025
7370299
add (solution): Решение swap_ptr
RIZONTE Dec 6, 2025
b7cb116
Merge branch 'main' of https://github.com/psds-cpp/psds-cpp-2025
RIZONTE Dec 15, 2025
280c7d6
add (solution): Решение data_stats
RIZONTE Dec 15, 2025
067405d
add (solution): Решение easy_compare
RIZONTE Dec 15, 2025
bc3dc9b
add (solution): Решение enum_operators
RIZONTE Dec 17, 2025
6e34b9c
Merge branch 'main' of https://github.com/psds-cpp/psds-cpp-2025
RIZONTE Dec 17, 2025
ce86dd7
modify (CMakeList): Закомментировал строчку в 4-й неделе, чтобы собир…
RIZONTE Dec 17, 2025
ea262f1
add (solution): Решение filter
RIZONTE Dec 17, 2025
7d1d00b
add (solution): Решение find_all
RIZONTE Dec 17, 2025
67e42d0
add (solution): Решение minmax
RIZONTE Dec 17, 2025
c46016a
add (solution): Решение os_overload
RIZONTE Dec 18, 2025
1b359da
add (solution): Решение range
RIZONTE Dec 18, 2025
c06738d
add (solution): Решение unique
RIZONTE Dec 18, 2025
01adc7e
Merge branch 'main' of https://github.com/psds-cpp/psds-cpp-2025
RIZONTE Dec 21, 2025
92d14f4
add (solution): Решение phasor, проходит первые 11 тестов
RIZONTE Dec 23, 2025
87cab48
Merge branch 'main' of https://github.com/psds-cpp/psds-cpp-2025
RIZONTE Dec 23, 2025
30bd518
add (solution): Решение phasor
RIZONTE Dec 24, 2025
ac16b5b
add (solution): Решение queue
RIZONTE Dec 26, 2025
795eb5b
add (solution): Решение ring_buffer(такое себе решение)
RIZONTE Dec 26, 2025
a78c741
add (solution): Решение stack
RIZONTE Dec 27, 2025
2796646
modify (solution): Исправления в queue, названия полей класса
RIZONTE Dec 27, 2025
440ba29
modify (solution): Исправление замечаний 1-й недели
RIZONTE Feb 6, 2026
e1bbc8e
modify (solution): Исправление замечаний 2-й недели
RIZONTE Feb 7, 2026
a8cc8e2
modify (solutions): Исправление замечаний 3-й недели, частично
RIZONTE Feb 8, 2026
4c1b18c
Merge branch 'main' of https://github.com/psds-cpp/psds-cpp-2025
RIZONTE Feb 8, 2026
c13e68d
add (solution): Решение tracer
RIZONTE Feb 8, 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
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
build/
.vs/
CMakeLists.txt.user
CMakeSettings.json
CMakeUserPresets.json
.vscode/
*.out
2 changes: 1 addition & 1 deletion 01_week/tasks/addition/addition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@


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


size_t CharChanger(char array[], size_t size, char delimiter = ' ') {
throw std::runtime_error{"Not implemented"};
//Массив для подстановки кол-ва повторений
char intToChar[10] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};

size_t i = 0;
size_t j = 1;
size_t str_end = 0;

int reps = 1; // кол-во повторений символа
while (j < size) {
if (array[i] == array[j]) {
++reps;
++j;
continue;
}

array[str_end] = array[i];
if (reps != 1 && array[i] != ' ') {
array[str_end+1] = reps < 10 ? intToChar[reps] : intToChar[0];
}

if (char c = array[str_end]; std::isalpha(c) && std::islower(c)) {
array[str_end] = std::toupper(c);
}
else if (array[str_end] == ' ') {
array[str_end] = delimiter;
++str_end;
i = j++;
reps = 1;
continue;
}
else if (std::isdigit(array[str_end])) {
array[str_end] = '*';
}
else if (!(std::isalpha(array[str_end]))) {
array[str_end] = '_';
}

if (reps == 1) {
++str_end;
}
else {
str_end+= 2;
reps = 1;
}
i = j++;
}
array[str_end] = '\0';
return str_end;
}
28 changes: 25 additions & 3 deletions 01_week/tasks/check_flags/check_flags.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <cstdint>
#include <stdexcept>

#include <iostream>
#include <string>

enum class CheckFlags : uint8_t {
NONE = 0,
Expand All @@ -14,5 +14,27 @@ enum class CheckFlags : uint8_t {
};

void PrintCheckFlags(CheckFlags flags) {
throw std::runtime_error{"Not implemented"};
uint8_t flags_uint8 = static_cast<uint8_t>(flags);

//Массив с именами флагов
std::string flagStr[6] = {"TIME", "DATE", "USER", "CERT", "KEYS", "DEST"};
//Если флаг больше ALL значит он выходит из диапазона значений флагов
if (static_cast<uint8_t>(flags) > static_cast<uint8_t>(CheckFlags::ALL)) {
std::cout << "";
return;
}
//В остальных случаях флаги перебираются и добавляюся в строку если присутствуют
uint8_t flag = 1;
bool str_write = false;
std::cout << "[";
for (size_t i = 0; flag < static_cast<uint8_t>(CheckFlags::ALL); ++i) {
if (flags_uint8 & flag) {
std::cout << (str_write ? "," : "");
std::cout << flagStr[i];
str_write = true;
}
flag *= 2;
}

std::cout << "]";
}
66 changes: 66 additions & 0 deletions 01_week/tasks/length_lit/length_lit.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
namespace {
constexpr double IN_IN_FT = 12.0; //дюймов в футе
constexpr double CM_IN_FT = 30.48; //сантиметров в футе
constexpr double CM_IN_M = 100; //сантиметров в метре
constexpr double CM_IN_IN = 2.54; //сантиметров в дюйме
}

//Футы в дюймы
constexpr double operator""_ft_to_in(long double ft) {
return ft * IN_IN_FT;
}

//Футы в сантиметры
constexpr double operator""_ft_to_cm(long double ft) {
return ft * CM_IN_FT;
}

//Футы в метры
constexpr double operator""_ft_to_m(long double ft) {
return (ft * CM_IN_FT) / CM_IN_M;
}

//Дюймы в футы
constexpr double operator""_in_to_ft(long double in) {
return in / IN_IN_FT;
}

//Дюймы в сантиметры
constexpr double operator""_in_to_cm(long double in) {
return in * CM_IN_IN;
}

//Дюймы в метры
constexpr double operator""_in_to_m(long double in) {
return (in * CM_IN_IN) / CM_IN_M;
}

//Сантиметры в футы
constexpr double operator""_cm_to_ft(long double cm) {
return cm / CM_IN_FT;
}

//Сантиметры в дюймы
constexpr double operator""_cm_to_in(long double cm) {
return cm / CM_IN_IN;
}

//Сантиметры в метры
constexpr double operator""_cm_to_m(long double cm) {
return cm / CM_IN_M;
}

//Метры в футы
constexpr double operator""_m_to_ft(long double m) {
return (m * CM_IN_M) / CM_IN_FT;
}

//Метры в дюймы
constexpr double operator""_m_to_in(long double m) {
return (m * CM_IN_M) / CM_IN_IN;
}

//Метры в сантиметры
constexpr double operator""_m_to_cm(long double m) {
return m * CM_IN_M;
}
15 changes: 12 additions & 3 deletions 01_week/tasks/print_bits/print_bits.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
#include <cstddef>
#include <stdexcept>

#include <iostream>

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

std::cout << "0b";
for (size_t i = bitLen - 1; i < bitLen; --i) {
std::cout << ((value >> i) % 2 == 0 ? '0' : '1');
if (i != 0 && i % 4 == 0) {
std::cout << '\'';
}
}

std::cout << "\n";
}
42 changes: 39 additions & 3 deletions 01_week/tasks/quadratic/quadratic.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,42 @@
#include <stdexcept>

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

void SolveQuadratic(int a, int b, int c) {
throw std::runtime_error{"Not implemented"};
//Установка точности вывода в 6 символов
std::cout << std::setprecision(6);

double eps = 1e-3; // Погрешность при сравнении double
double x1{0}, x2{0};
if (a == 0 && b == 0 && c != 0) {
std::cout << "no solutions";
return;
}
if (a == 0 && b == 0 && c == 0) {
std::cout << "infinite solutions";
return;
}
if(b != 0 && a == 0){
x1 = -c / static_cast<double>(b);
std::cout << x1;
return;
}

long long d = static_cast<long long>(b) * b - 4 * static_cast<long long>(a) * c;
if(d < 0){
std::cout << "no solutions";
return;
}

x1 = (-b + sqrt(d)) / (2*a);
x2 = (-b - sqrt(d)) / (2*a);
if((x1 - x2) < eps){
std::cout << x1;
}
else{
if(x1 > x2){
std::swap(x1, x2);
}
std::cout << x1 << " " << x2;
}
}
13 changes: 11 additions & 2 deletions 01_week/tasks/rms/rms.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
#include <cstdef>
#include <cstddef>
#include <stdexcept>
#include <cmath>


double CalculateRMS(double values[], size_t size) {
throw std::runtime_error{"Not implemented"};
if(values == nullptr || size == 0){
return 0.0;
}

double res {0.0};
for(size_t i = 0; i < size; ++i){
res += values[i] * values[i];
}
return std::sqrt(res / size);
}
13 changes: 10 additions & 3 deletions 02_week/tasks/func_array/func_array.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
#include <stdexcept>
#include <cstddef>


double ApplyOperations(double a, double b /* other arguments */) {
throw std::runtime_error{"Not implemented"};
double ApplyOperations(double a, double b, double (**functions)(double, double), size_t size) {
if(size == 0) return 0.0;

double res{};
for(size_t i = 0; i < size; ++i){
res += !functions[i] ? 0.0 : functions[i](a, b);
}

return res;
}
9 changes: 6 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,9 @@
#include <stdexcept>

const int* FindLastElement(const int* begin, const int* end, bool (*predicate)(int)) {
if(begin == nullptr || end == nullptr || begin > end) return end;

/* return_type */ FindLastElement(/* ptr_type */ begin, /* ptr_type */ end, /* func_type */ predicate) {
throw std::runtime_error{"Not implemented"};
for(const int* current = (end-1); current != begin-1; --current){
if(predicate(*current)) return current;
}
return end;
}
28 changes: 23 additions & 5 deletions 02_week/tasks/little_big/little_big.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,28 @@
#include <stdexcept>
#include <iostream>
#include <cstddef>
#include <iomanip>

void PrintHex(const unsigned char* ptr, const size_t size, bool inverse) {
for (size_t i = 0; i < size; ++i) {
std::cout << std::uppercase << std::hex << std::setw(2) << std::setfill('0')
<< (!inverse ? static_cast<unsigned int>(ptr[i]) : static_cast<unsigned int>(ptr[size - 1 - i]));
}
}

void PrintMemory(int /* write arguments here */) {
throw std::runtime_error{"Not implemented"};
void PrintMemory(int num, bool inverse = false) {
const size_t size = sizeof(int);
auto ptr = reinterpret_cast<const unsigned char*>(&num);

std::cout << "0x";
PrintHex(ptr, size, inverse);
std::cout << std::endl;
}

void PrintMemory(double /* write arguments here */) {
throw std::runtime_error{"Not implemented"};
void PrintMemory(double num, bool inverse = false) {
const size_t size = sizeof(double);
auto ptr = reinterpret_cast<const unsigned char*>(&num);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

идет полное дублирование кода, после получения указателя и, зная sizeof типа num, можно было вызвать третью функцию без дублирования кода

std::cout << "0x";
PrintHex(ptr, size, inverse);
std::cout << std::endl;
}
29 changes: 26 additions & 3 deletions 02_week/tasks/longest/longest.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,29 @@
#include <stdexcept>
#include <cstddef>

const char* FindLongestSubsequence(const char* begin, const char* end, size_t& count) {
const char* res{nullptr};
count = 0;

/* return_type */ FindLongestSubsequence(/* ptr_type */ begin, /* ptr_type */ end, /* type */ count) {
throw std::runtime_error{"Not implemented"};
if(begin == nullptr || end == nullptr) return nullptr;

size_t curLen{1};
const char* curBegin{begin};
for(const char* curent = begin; curent < end; ++curent){
if(curent+1 != end && *curent == *(curent+1)){
curBegin = curLen == 1 ? curent : curBegin;
++curLen;
continue;
}

res = count < curLen ? curBegin : res;
count = count < curLen ? curLen : count;
curLen = 1;
}

return res;
}

char* FindLongestSubsequence(char* begin, char* end, size_t& count) {
const char* const_res = FindLongestSubsequence(const_cast<const char*>(begin), const_cast<const char*>(end), count);
return const_cast<char*>(const_res);
}
25 changes: 22 additions & 3 deletions 02_week/tasks/pretty_array/pretty_array.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
#include <stdexcept>
#include <iostream>


void PrintArray(/* write arguments here */) {
throw std::runtime_error{"Not implemented"};
void PrintArray(const int* begin, const int* end, size_t limit = 0) {
if(begin == nullptr || end == nullptr) {
std::cout << "[]\n";
return;
}

std::cout << "[";
int step = begin > end ? -1 : 1;
size_t i = 1;
for(const int* curent = begin; curent != end; curent += step) {
if(limit != 0 && i > limit) {
std::cout << "...\n " << *curent << (curent+step == end ? "" : ", ");
i = 1;
}
else {
std::cout << *curent << (curent+step == end ? "" : ", ");
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

практически полное дублирование кода, можнобыло например по условию определить шаг и потом шагать с этим шагом, используя один for, и переписав немного логику

++i;
}

std::cout << "]\n";
}
Loading