Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <string>
- #include <sstream>
- #include <vector>
- #include <cmath>
- template <class T>
- class Matrix {
- private:
- std::vector<std::vector<T>> Matr;
- public:
- Matrix(const std::vector<std::vector<T>>& matrix) {
- Matr = matrix;
- }
- std::pair<size_t , size_t> size() const {
- if (Matr.empty()) {
- return {0, 0};
- } else {
- return {Matr.size(), Matr.front().size()};
- }
- }
- };
- std::ostream& operator << (std::ostream& out, const Matrix& mat) {
- std::string outLine;
- std::stringstream os(outLine);
- for (auto& line : mat.Matr) {
- for (auto& elem : line) {
- os << elem << "\t";
- }
- outLine.pop_back();
- os << "\n";
- }
- outLine.pop_back();
- out << outLine;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement