Advertisement

c++代码用于开发下三角矩阵的相关功能

阅读量:

30.设A与B为两个n×n的下三角矩阵。在非零元素区域中,其包含的元素总数为n(n+1)。请设计一种映射机制,采用element[n+1][n]的形式来表达这两个矩阵。
针对矩阵A和B,分别编写用于获取数值及存储数据的函数。

复制代码
    #include <iostream>
     using namespace std;
      template <class T>
      class matrix{
      	public :
      		matrix(int theRows = 0, int theColumns=0)
    		  {
    		  	this->theColumns=theColumns;
    		  	this->theRows=theRows;
    		  	element= new T [theRows*theColumns];
    		  };
      		~matrix(){ delete [] element;}
      		int rows() const {return theRows;}
    		int columns()  const {return theColumns;}
    		void setrows(int rows=0) const {t

全部评论 (0)

还没有任何评论哟~