p53_54test.cpp
资源名称:ds1-3.rar [点击查看]
上传用户:chaiyuqiu
上传日期:2022-08-03
资源大小:27k
文件大小:1k
源码类别:
数据结构
开发平台:
C/C++
- //Test is T55_59.cpp
- #include <iostream.h>
- const int MaxTerms = 100;
- template <class Type> class SparseMatrix; //稀疏矩阵的类声明
- template <class Type> class Trituple { //三元组类Trituple
- friend class SparseMatrix<Type> ;
- friend istream & operator >> ( istream & , SparseMatrix<Type> & );
- friend ostream & operator << ( ostream & , SparseMatrix<Type> & );
- private:
- int row, col; //非零元素的行号、列号
- Type value; //非零元素的值
- };
- template <class Type> class SparseMatrix {
- //对象: 是一个三元组<row, column, value>的集合。其中, row和column是整数, 记忆矩阵
- //元素所在的行号和列号,而value是矩阵元素的值。
- friend istream & operator >> ( istream & , SparseMatrix<Type> & );
- friend ostream & operator << ( ostream & , SparseMatrix<Type> & );
- public:
- SparseMatrix ();
- SparseMatrix ( int MaxRow, int MaxCol ): Rows( MaxRow ), Cols( MaxCol ){}; //构造函数
- //建立一个MaxRow行, Maxcol列的稀疏矩阵。
- SparseMatrix<Type> Transpose ( );
- //对*t