p53_54test.cpp

来自「清华大学数据结构的教程源码,c++版的,有助于提高自已对数据结构的认识」· C++ 代码 · 共 29 行

CPP
29
字号
//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

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?