geekbrains_cpp_difficult_mo.../lesson_3/exercise_2.hpp

53 lines
1.4 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* exercise_2.hpp
*
* Created on: 29 сент. 2021 г.
* Author: alexander
*/
#pragma once
#include <cstddef>
/*
* Т.к. определитель (детрминант) вычисляется только для квадратной матрицы,
* то объект класса инициализируется одним положительным целочисленным значением.
*/
class Matrix
{
private:
const size_t matrixSize;
const size_t matrixCapacity;
double *array;
double matrixDeterminant { 0.0 };
Matrix getModifiedMatrix(Matrix &arr, const size_t item);
double calculateDeterminant(Matrix &arr);
public:
Matrix(const int size);
void fillRandom(); // заполнить массив случайными значениями
void print() const; // распечатать массив
size_t size() const; // получить размер массива
double determinant() const; // получить определитель матрицы
class Iterator
{
private:
double *current;
public:
Iterator(double *pointer);
double& operator[](size_t i);
Iterator& operator ++();
bool operator !=(const Iterator &iterator);
double& operator *();
};
Iterator operator[](size_t i);
Iterator begin();
Iterator end();
~Matrix();
};
void exercise_2();