30.令A和B是两个n×n的下三角矩阵。它们在非0区域的元素个数是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 {
theRows=rows;}
void setcolumns(int columns=0) const {
theColumns=columns;}
void setelement(T *element){
this->element=element;
}
void setelement1(T a,int position){
this->element[position]=a;
}
T getelement(int i=0){
return element[i];
}
matrix<T> reverse(