Advertisement
Mikhail-Podbolotov

Untitled

Apr 24th, 2024
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. #pragma once
  2. #include <fstream>
  3. struct Element {
  4.     int row;
  5.     int col;
  6.     int value;
  7.     Element* next = nullptr;
  8.     Element(int, int, int);
  9. };
  10.  
  11. class SparseMatrix {
  12. private:
  13.     Element* Start = nullptr;
  14.     Element* End = nullptr;
  15.     int rows;
  16.     int cols;
  17. public:
  18.     SparseMatrix(int, int);
  19.     ~SparseMatrix();
  20.     void addElement(int row, int col, int value);
  21.     void Read(std::ifstream& file1);
  22.     void Sort();
  23.     void Print(std::ofstream& file2);
  24.     SparseMatrix& operator+=(const SparseMatrix& other);
  25.     SparseMatrix& operator-=(const SparseMatrix& other);
  26.     SparseMatrix& operator=(const SparseMatrix& other);
  27.     SparseMatrix& operator*=(const double a);
  28.     SparseMatrix& operator*=(const SparseMatrix& other);
  29. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement