Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
3ef92fc
Added lib_point, lib_point3d, lib_circle, lib_sphere with full implem…
Kate-Nits Sep 14, 2025
a0807dd
Changed double to float, implemented test_point
Kate-Nits Sep 14, 2025
e0d37da
implemented test_point3d
Kate-Nits Sep 14, 2025
6ef62b6
Added operator == for class point and implemented test_circle
Kate-Nits Sep 14, 2025
6b08d0c
Added operator == for class Point3D and implemented test_sphere
Kate-Nits Sep 14, 2025
820ae8c
Did application: show position of two circle or two srhere with user …
Kate-Nits Sep 15, 2025
09d4680
Added lib_algorithms which have check_circle_position and check_spher…
Kate-Nits Sep 16, 2025
e5be3a9
Added tests copy_constructor_with_throw
Kate-Nits Sep 16, 2025
a6365f1
Added tests parameterized_constructor_with_radius_less_than_zero
Kate-Nits Sep 16, 2025
66af1bb
Edits made by Marina Andreevna: redone the functions check_position a…
Kate-Nits Sep 17, 2025
65ba083
Started writing the function matrix_application, wrote the methods st…
Kate-Nits Sep 17, 2025
497ceb9
Started writing the function matrix_application, wrote the methods in…
Kate-Nits Sep 18, 2025
b3fde40
I did the third job of the terminal class: Implemented the interface …
Kate-Nits Sep 18, 2025
1e97ef8
Added a normal implementation of the class TVector without tests
Kate-Nits Sep 24, 2025
8b08028
Rewrote the tests for the classes Point, Point3D, Circle, Sphere
Kate-Nits Sep 24, 2025
2d0fa92
Added tests to check the constructors of the class TVector
Kate-Nits Sep 24, 2025
e46803c
Added tests to check at()
Kate-Nits Sep 25, 2025
8dc09eb
Added tests to check state()
Kate-Nits Sep 25, 2025
b89c710
Added tests to check front()
Kate-Nits Sep 25, 2025
ffbf8c7
Added tests to check back()
Kate-Nits Sep 25, 2025
38aec5a
Added tests to check begin() and end()
Kate-Nits Sep 25, 2025
1347906
Added test to check assign
Kate-Nits Sep 25, 2025
c1cb5ed
Added test to check operators equal and not equal
Kate-Nits Sep 25, 2025
c0d01d6
Added test to check operator =
Kate-Nits Sep 25, 2025
d16d401
Added test to check clear
Kate-Nits Sep 25, 2025
d313ce3
Added test to check resize
Kate-Nits Sep 25, 2025
da11f1e
Added test to check is_empty
Kate-Nits Sep 25, 2025
aedd58a
Added test to check push_front
Kate-Nits Sep 25, 2025
7947bb7
Added test to check push_back
Kate-Nits Sep 25, 2025
0658365
Added test to check insert
Kate-Nits Sep 25, 2025
fbc9e0b
Added test to check pop_front
Kate-Nits Sep 26, 2025
c294906
Added test to check pop_back
Kate-Nits Sep 26, 2025
8a9b3c2
Added test to check erase
Kate-Nits Sep 26, 2025
abc50a8
Added test to check emplace
Kate-Nits Sep 26, 2025
4b540ab
Added test to check pop_back where vec has size equal 0
Kate-Nits Sep 26, 2025
21471e2
Added test to check shuffle
Kate-Nits Sep 26, 2025
e3a7c92
Added test to check quick_sort
Kate-Nits Sep 26, 2025
db4ebb0
Added test to check find_first and find_last
Kate-Nits Sep 26, 2025
e901865
Added test to check find_all
Kate-Nits Sep 26, 2025
8fbbd61
Added test to check push_front with reserve
Kate-Nits Sep 26, 2025
d78f5f6
Added test to check push_back with reserve
Kate-Nits Sep 26, 2025
3212f5d
Added test to check insert with reserve and throw out of range
Kate-Nits Sep 26, 2025
198eb1c
Added test to check pop_front with shrink to fit
Kate-Nits Sep 26, 2025
ce59712
Added test to check erase with shrink to fit
Kate-Nits Sep 26, 2025
1ee5f93
I have finished all the tests. Added tests for checking test data, ca…
Kate-Nits Sep 27, 2025
a3e288f
Added constructions for class MathVector
Kate-Nits Sep 27, 2025
0735963
Wrote constructions for class MathVector and added tests for these co…
Kate-Nits Sep 27, 2025
6247124
Added tests on class MathVector checking public function from TVector
Kate-Nits Sep 27, 2025
4706571
Added operator + for MathVector and test on it
Kate-Nits Sep 27, 2025
dd4d997
Added operator -, operator * for MathVector and tests on it
Kate-Nits Sep 27, 2025
4d1668a
Wrote operators +=, -=, *=, function length of the vector and added t…
Kate-Nits Sep 27, 2025
2e52da4
Wrote conversion constructor and added test on it
Kate-Nits Sep 27, 2025
cd71dc8
Wrote operator + which accepts different types, and wrote tests that …
Kate-Nits Sep 27, 2025
4210377
Wrote operator - which accepts different types, and wrote tests that …
Kate-Nits Sep 27, 2025
759f397
Wrote operator * which accepts different types, and wrote tests that …
Kate-Nits Sep 27, 2025
30a5676
Done wrote class MathVecot and added more tests on this class
Kate-Nits Sep 28, 2025
286d2fe
Start to write the class Matrix. Fixed an error that Visual Studio wr…
Kate-Nits Oct 1, 2025
e21d402
Wrote operator= for class Matrix and added test on it
Kate-Nits Oct 1, 2025
ca60322
Wrote operator[] and rewrote at for class Matrix and added tests on it
Kate-Nits Oct 1, 2025
9430466
Wrote transpose() for class Matrix and added test on it
Kate-Nits Oct 1, 2025
8ebab1f
Rewrote constructor with initializer_list for class Matrix. I added c…
Kate-Nits Oct 1, 2025
23c66e5
Wrote operator - for class Matrix and added tests on it
Kate-Nits Oct 1, 2025
b7da4b8
Wrote operator * for class Matrix and added tests on it
Kate-Nits Oct 1, 2025
6f71b13
Wrote print() and << for class Matrix. Done wrote all functions and m…
Kate-Nits Oct 2, 2025
63a50c8
Finished writing the class Matrix and wrote all the test for it
Kate-Nits Oct 3, 2025
9f2fb66
Wrote all constructors for class TriangleMatrix and tests on it. Also…
Kate-Nits Oct 4, 2025
4ff9a42
Wrote operator + and - for the class TriangleMatrix and added tests o…
Kate-Nits Oct 5, 2025
811439f
Added test on throw for operator + and - for the class TriangleMatrix
Kate-Nits Oct 5, 2025
46cc11d
Wrote operator * on scalar, vector and TriangleMatrix for the class T…
Kate-Nits Oct 5, 2025
ab730f2
Wrote operator << <> for the class TriangleMatrix, also wrote operato…
Kate-Nits Oct 5, 2025
3b916b2
Wrote operator - on Matrix and TriangleMatrix and on TriangleMatrix a…
Kate-Nits Oct 5, 2025
c58b4fa
Wrote operator * on Matrix and TriangleMatrix and on TriangleMatrix a…
Kate-Nits Oct 5, 2025
64c36ed
Input the classes Matrix and TriangleMatrix in matrix application
Kate-Nits Oct 6, 2025
09a10f9
Finished writing the matrix calculator application, fixed all the log…
Kate-Nits Oct 6, 2025
7c8d51f
Wrote function gradient_descent and added tests on it
Kate-Nits Oct 7, 2025
d1a709e
Started wrote Stack, added default constructor, constructor with size…
Kate-Nits Oct 14, 2025
4400154
Wrote push and top for Stack and added tests on it
Kate-Nits Oct 14, 2025
7447ded
I finished writing Stack, wrote pop, and added all the tests for each…
Kate-Nits Oct 14, 2025
3f337f6
I finished writing Queue and added all tests on it
Kate-Nits Oct 14, 2025
6b04a2c
I fixed all Marina Andreevna's comments about the stack and queue cla…
Kate-Nits Dec 3, 2025
f99e4a0
Removed the user input and made a random choice of the position in th…
Kate-Nits Dec 4, 2025
31a50d8
I added lib_node and lib_list, declared them and wrote an realization…
Kate-Nits Dec 6, 2025
b0e4a35
Wrote the class List and wrote all tests for it
Kate-Nits Dec 7, 2025
fb00bf9
Moved the realization of methods outside the class List
Kate-Nits Dec 7, 2025
06d7da7
Added functions is_open_bracket, is_close_bracket, matches_pair, chec…
Kate-Nits Dec 8, 2025
84d05a0
Added Iterator for the class List and wrote tests on it
Kate-Nits Dec 8, 2025
71e0ac7
Wrote NodeD, DList, Iterator for DList and wrote tests for it
Kate-Nits Dec 9, 2025
d229deb
Wrote Iterator for TVector and added tests on it
Kate-Nits Dec 9, 2025
f32e99b
Moved the realization of the methods of the class TVector outside of …
Kate-Nits Dec 9, 2025
e2e0ea5
Added function is_looped_hare_and_turtle, is_looped_turn_ptr and find…
Kate-Nits Dec 9, 2025
36a0889
Edits from Marina Andreevna and wrote tests for functions is_looped_h…
Kate-Nits Dec 9, 2025
5ae8991
I Fixed everything that Marina Andreevna told me about arithmetic ope…
Kate-Nits Dec 10, 2025
3a7057c
Created lib_stack_list and lib_queue_list. Wrote a StackList class an…
Kate-Nits Dec 11, 2025
691568d
Wrote class QueueList and added all tests for it
Kate-Nits Dec 11, 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
16 changes: 16 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,22 @@ include(cmake/function.cmake) # подхватываем функции,
# и для создания исполняемого проекта в отдельные функции

add_subdirectory(lib_easy_example) # подключаем дополнительный CMakeLists.txt из подкаталога с именем lib_easy_example
add_subdirectory(lib_algorithms)
add_subdirectory(lib_point)
add_subdirectory(lib_circle)
add_subdirectory(lib_point3d)
add_subdirectory(lib_sphere)
add_subdirectory(lib_tvector)
add_subdirectory(lib_mathvector)
add_subdirectory(lib_matrix)
add_subdirectory(lib_triangle_matrix)
add_subdirectory(lib_stack)
add_subdirectory(lib_queue)
add_subdirectory(lib_node)
add_subdirectory(lib_list)
add_subdirectory(lib_dlist)
add_subdirectory(lib_stack_list)
add_subdirectory(lib_queue_list)
add_subdirectory(main) # подключаем дополнительный CMakeLists.txt из подкаталога с именем main

option(BTEST "build test?" ON) # указываем подключаем ли google-тесты (ON или YES) или нет (OFF или NO)
Expand Down
8 changes: 8 additions & 0 deletions lib_algorithms/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
create_project_lib(Algorithms)
add_depend(Algorithms Circle lib_circle)
add_depend(Algorithms Sphere lib_sphere)
add_depend(Algorithms Stack lib_stack)
add_depend(Algorithms Node lib_node)
add_depend(Algorithms List lib_list)
add_depend(Algorithms Matrix lib_matrix)
add_depend(Algorithms TriangleMatrix lib_triangle_matrix)
500 changes: 500 additions & 0 deletions lib_algorithms/algorithms.cpp

Large diffs are not rendered by default.

288 changes: 288 additions & 0 deletions lib_algorithms/algorithms.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,288 @@
// Copyright 2025 Ekaterina Ushnitskaya


#ifndef LIB_ALGORITHMS_H
#define LIB_ALGORITHMS_H

#include <cstdlib>
#include "../lib_circle/circle.h"
#include "../lib_sphere/sphere.h"
#include "../lib_tvector/tvector.h"
#include "../lib_mathvector/MathVector.h"
#include "../lib_matrix/matrix.h"
#include "../lib_triangle_matrix/triangle_matrix.h"
#include "../lib_stack/stack.h"
#include "../lib_node/node.h"
#include "../lib_list/list.h"

#define START_MENU_MATRIX_SIZE 3
#define REALISED_Matrix

#define NUMBER1 1
#define NUMBER2 2
#define NUMBER3 3
#define NUMBER4 4

template <class T> class Matrix;
template <class T> class TriangleMatrix;

enum Location { intersecting, do_not_intersecting, tangent, inside, coinside };
//tangent - ����������, intersecting - ��������������, inside - ���� � ������, coinside - ���������

void set_color(int text_color, int bg_color);
void print_result_position(const std::string& description, Location result);
void in_development();

template <class T>
Location check_position(const T& circle1, const T& circle2) {
Point center1 = circle1.get_center();
Point center2 = circle2.get_center();
int radius1 = circle1.get_radius();
int radius2 = circle2.get_radius();

double distance = center1.distance_to(center2);
int sum_rad = radius1 + radius2;
int abs_difference = std::abs(radius1 - radius2);

if (distance == 0 && radius1 == radius2) {
return coinside; // ���������� ���������
}
else if (distance < abs_difference) {
return inside; // ���� ���������� ������ ������
}
else if (distance == abs_difference) {
return tangent; // ���������� �������
}
else if (distance < sum_rad && distance > abs_difference) {
return intersecting; // ���������� ������������
}
else if (distance == sum_rad) {
return tangent; // ������� �������
}
else {
return do_not_intersecting; // ���������� �� ������������
}
}

template <class T>
bool has_unique_elements(const Matrix<T>& matrix) {
TVector<T> elements;
for (size_t i = 0; i < matrix.rows(); i++) {
for (size_t j = 0; j < matrix.cols(); j++) {
elements.push_back(matrix.at(i, j));
}
}
quick_sort(elements);
for (size_t i = 1; i < elements.size(); ++i) {
if (elements[i] == elements[i - 1]) { return false; }
}
return true;
}
template <class T>
int what_number_less(const T& num1, const T& num2, const T& num3, const T& num4) {
if (num1 < num2 && num1 < num3 && num1 < num4) {
return NUMBER1;
}
else if (num2 < num1 && num2 < num3 && num2 < num4) {
return NUMBER2;
}
else if (num3 < num1 && num3 < num2 && num3 < num4) {
return NUMBER3;
}
else {
return NUMBER4;
}
}
template <class T>
T gradient_descent(const Matrix<T>& matrix) {
srand(time(0));
if (matrix.cols() != matrix.rows()) {
throw std::invalid_argument("The Matrix should be square");
}
if (!has_unique_elements(matrix)) {
throw std::invalid_argument("The Matrix should has only unique elements");
}

size_t start_row_pos = 0, start_col_pos = 0;
start_row_pos = rand() % matrix.rows() + 0;
start_col_pos = rand() % matrix.cols() + 0;

if (start_row_pos >= matrix.rows() || start_col_pos >= matrix.cols()) {
throw std::out_of_range("Start position out of matrix bounds");
}

T current_value = matrix.at(start_row_pos, start_col_pos);
size_t current_row = start_row_pos;
size_t current_col = start_col_pos;

const size_t max_steps = matrix.rows() * matrix.cols();
size_t steps = 0;
bool improved = true;

while (improved && steps < max_steps) {
improved = false;
T best_neighbor_value = current_value;
size_t best_neighbor_row = current_row;
size_t best_neighbor_col = current_col;

if (current_row > 0) { // �����
T up_value = matrix.at(current_row - 1, current_col);
if (up_value < best_neighbor_value) {
best_neighbor_value = up_value;
best_neighbor_row = current_row - 1;
best_neighbor_col = current_col;
improved = true;
}
}

if (current_col < matrix.cols() - 1) { // ������
T right_value = matrix.at(current_row, current_col + 1);
if (right_value < best_neighbor_value) {
best_neighbor_value = right_value;
best_neighbor_row = current_row;
best_neighbor_col = current_col + 1;
improved = true;
}
}

if (current_row < matrix.rows() - 1) { // ����
T down_value = matrix.at(current_row + 1, current_col);
if (down_value < best_neighbor_value) {
best_neighbor_value = down_value;
best_neighbor_row = current_row + 1;
best_neighbor_col = current_col;
improved = true;
}
}

if (current_col > 0) { // �����
T left_value = matrix.at(current_row, current_col - 1);
if (left_value < best_neighbor_value) {
best_neighbor_value = left_value;
best_neighbor_row = current_row;
best_neighbor_col = current_col - 1;
improved = true;
}
}

if (improved) {
current_row = best_neighbor_row;
current_col = best_neighbor_col;
current_value = best_neighbor_value;
steps++;
}
}
std::cout << "Final value: " << current_value << std::endl;

return current_value;
}

void start_menu_for_matrix();
void viewing_saved_matrices(int count_of_saved_matrices, Matrix<int> matrix1, Matrix<int> matrix2, Matrix<int> matrix3);
void start_matrix_calculator(int& link_user_choice, int& link_want_to_save, Matrix<int> res, int& count_of_saved_matrices, Matrix<int>& matrix1, Matrix<int>& matrix2, Matrix<int>& matrix3, int& isThereMatrix1, int& isThereMatrix2, int& isThereMatrix3);
void do_user_want_to_save(int& want_to_save);
void input_standart_matrix(Matrix<int>& matrix, size_t rows, size_t cols);
void input_triangle_matrix(TriangleMatrix<int>& matrix, size_t n);
Matrix<int> triangle_to_full(const TriangleMatrix<int>& matrix);
void check_user_input(int user_choice, int true_number);
bool input_user_choice(int& user_choice, int true_number);
void what_matrices(int& what_the_first_matrix, int& what_the_second_matrix, int& isExit);
void print_menu_matrix_calculator();
void what_matrix_sizes(const int& type_matrix, size_t& size_rows, size_t& size_cols);
void deleted_saved_matrix(int& link_user_choice_for_deleted, int& isThereMatrix1, int& isThereMatrix2, int& isThereMatrix3);
void matrix_application();

inline bool is_open_bracket(char symbol);
inline bool is_close_bracket(char symbol);
inline bool matches_pair(char open, char close);
bool check_brackets(const std::string& str);

template <class T>
bool is_looped_hare_and_turtle(List<T>& list) {
Node<T>* head = list.head();
if (head == nullptr) {
return false;
}
Node<T>* fast = head;
Node<T>* slow = head;
while (fast != nullptr && fast->next != nullptr) {
slow = slow->next;
fast = fast->next->next;
if (slow == fast) {
return true;
}
}
return false;
}

template <class T>
bool is_looped_turn_ptr(List<T>& list) {
Node<T>* head = list.head();
if (head == nullptr || head->next == nullptr) {
return false;
}

Node<T>* cur = head;
Node<T>* prev = nullptr;
Node<T>* next = nullptr;

while (cur != nullptr) {
next = cur->next;
cur->next = prev;
prev = cur;
cur = next;

if (cur == head) {
cur = prev;
prev = nullptr;
while (cur != nullptr) {
next = cur->next;
cur->next = prev;
prev = cur;
cur = next;
}
return true;
}
}
cur = prev;
prev = nullptr;
while (cur != nullptr) {
next = cur->next;
cur->next = prev;
prev = cur;
cur = next;
}
return false;
}

template <class T>
Node<T>* find_loop_node(List<T>& list) {
Node<T>* head = list.head();
if (head == nullptr) {
return nullptr;
}
Node<T>* slow = head;
Node<T>* fast = head;
bool has_loop = false;
while (fast != nullptr && fast->next != nullptr) {
slow = slow->next;
fast = fast->next->next;
if (slow == fast) {
has_loop = true;
break;
}
}
if (!has_loop) {
return nullptr;
}
if (slow == fast) {
slow = head;
while (slow != fast) {
slow = slow->next;
fast = fast->next;
}
return slow;
}
return nullptr;
}
#endif // LIB_ALGORITHMS_H
2 changes: 2 additions & 0 deletions lib_circle/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
create_project_lib(Circle)
add_depend(Circle Point lib_point)
38 changes: 38 additions & 0 deletions lib_circle/circle.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright 2025 Ekaterina Ushnitskaya

#include <stdexcept>
#include <iostream>
////#include "../lib_point/point.h"
#include "../lib_circle/circle.h"


Circle::Circle() : _center(Point()), _radius(1) {};
Circle::Circle(Point value_dot, int value_rad) {
if (value_rad < 0) {
throw std::logic_error("Error!!! The radius can't be less than zero");
}
_center = value_dot;
_radius = value_rad;
}

Circle::Circle(const Circle& other) {
if (&other == NULL) {
throw std::logic_error("Error!!!");
}
_center = other._center;
_radius = other._radius;
}

Point Circle::get_center() const {
return _center;
}
int Circle::get_radius() const {
return _radius;
}

void Circle::set_center(Point dot) {
_center = dot;
}
void Circle::set_radius(int rad) {
_radius = rad;
}
24 changes: 24 additions & 0 deletions lib_circle/circle.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright 2025 Ekaterina Ushnitskaya

#ifndef LIB_CIRCLE_CIRCLE_H
#define LIB_CIRCLE_CIRCLE_H

#include "../lib_point/point.h"


class Circle {
Point _center;
int _radius;
public:
Circle();
Circle(Point, int);
Circle(const Circle&);

Point get_center() const;
int get_radius() const;

void set_center(Point);
void set_radius(int);
};

#endif // LIB_CIRCLE_CIRCLE_H
2 changes: 2 additions & 0 deletions lib_dlist/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
create_project_lib(DList)
add_depend(DList Node lib_node)
Empty file added lib_dlist/dlist.cpp
Empty file.
Loading