daily pastebin goal
65%
SHARE
TWEET

Untitled

a guest Dec 7th, 2017 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <fstream>
  3. #include <string>
  4. #include <sstream>
  5. #include <vector>
  6. #include <cmath>
  7.  
  8.  
  9. template <class T>
  10. class Matrix {
  11. private:
  12.     std::vector<std::vector<T>> Matr;
  13. public:
  14.     Matrix(const std::vector<std::vector<T>>& matrix) {
  15.         Matr = matrix;
  16.     }
  17.  
  18.     std::pair<size_t , size_t> size() const {
  19.         if (Matr.empty()) {
  20.             return {0, 0};
  21.         } else {
  22.             return {Matr.size(), Matr.front().size()};
  23.         }
  24.     }
  25. };
  26.  
  27. std::ostream& operator << (std::ostream& out, const Matrix& mat) {
  28.     std::string outLine;
  29.     std::stringstream os(outLine);
  30.     for (auto& line : mat.Matr) {
  31.         for (auto& elem : line) {
  32.             os << elem << "\t";
  33.         }
  34.         outLine.pop_back();
  35.         os << "\n";
  36.     }
  37.     outLine.pop_back();
  38.     out << outLine;
  39. }
RAW Paste Data
Top