Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "matrix.h"
- #define _CRT_SECURE_NO_WARNINGS
- #include <math.h>
- #include <cstdio>
- #include <locale.h>
- #include <iostream>
- #include < cstdlib >
- //Классы должны соответствующим образом перегружать те операторы из набора (не менее семи): -, +,*,/,<,>,!=,==, которые имеют смысл для типа данных вашего вариант
- class matrix
- {
- private:
- int size;
- // int str;
- int* arr;
- public:
- matrix()//конструктор ничего не ввдоим
- {
- size = 2;
- int** arr = new int* [2];
- for (int i = 0; i < 2; i++) {
- arr[i] = new int[2];
- }
- for (int i = 0; i < 2; i++)
- {
- for (int j = 0; j < 2; j++)
- {
- arr[i] = 0;
- }
- }
- printf("Вызван конструктр1");
- }
- matrix(int n) //конструктор ничего не ввдоим
- {
- if (n < 2) {
- printf("Неправильно введен размер для матрицы ");
- exit(-2);
- }
- size = n;
- int** arr = new int* [size];
- for (int i = 0; i < size; i++) {
- arr[i] = new int[size];
- }
- printf("Вызван конструктр2");
- } matrix operator *(const matrix& other) //переделать.
- {
- matrix temp;
- if (this->size != other.size) {
- printf("Разный размер матриц");
- return temp;
- }
- matrix temp1(this->size);
- for (int i = 0; i < size; i++)
- {
- for (int j = 0; j < size; j++)
- {
- temp1.arr[i] = this->arr[i] * other.arr[i]; //изменить умножение
- }
- }
- return temp1;
- size_t i, j;
- for (i = 0; i < size; ++i)
- for (j = 0; j < size; ++j)
- {
- size_t k;
- result[i][j] = 0;//проблемое место
- for (k = 0; k < size; ++k)
- result[i][j] += this->arr[i][k] * other.arr[k][j];
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment