Untitled
unknown
c_cpp
3 years ago
1.7 kB
6
Indexable
//
// ФАЙЛ main.cpp
//
#include <iostream>
#include "Matrix.h"
using namespace std;
int main() {
Matrix first;
//матриця, що створена конструктором без параметрів.
cout << "First matrix:\n" << first << endl;
int rows = 2, columns = 2;
auto** ptr = new float* [rows];
ptr[0] = new float[columns];
ptr[1] = new float[columns];
ptr[0][0] = 1;
ptr[0][1] = 2;
ptr[1][0] = 3;
ptr[1][1] = 4;
//матриця, що створена конструктором з параметрами.
Matrix second(rows, columns, ptr);
cout << "Second matrix:\n" << second << endl;
//матриця, що створена конструктором копіювання.
Matrix third(first);
cout << "Third matrix:\n" << third << endl;
//матриця, що введена з клавіатури.
Matrix fourth;
cin >> fourth;
cout << "Fourth matrix:\n" << fourth << endl;
//Результат оператора =
third = fourth;
cout << "Third=Fourth:\n" << third << endl;
//Результат оператора +=
third += fourth;
cout << "Third+=Fourth:\n" << third << endl;
//Результат оператора -=
third -= fourth;
cout << "Third-=Fourth:\n" << third << endl;
//Результат оператора *=
third *= fourth;
cout << "Third*=Fourth:\n" << third << endl;
Matrix fifth;
//Результат оператора +
fifth = third + fourth;
cout << "Fifth=Third+Fourth:\n" << fifth << endl;
//Результат оператора -
fifth = third - fourth;
cout << "Fifth=Third-Fourth:\n" << fifth << endl;
}Editor is loading...