⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 matrix.h

📁 使用c++实现矩阵的各种运算 
💻 H
字号:
#ifndef HEADER_MATRIX
#define HEADER_MATRIX

//template <typename T>
#include <iostream>
using namespace std;
class Matrix 
{
      private :
              int  nRow ,nCol ;
              
      public  : 
              int **Array ;

              //构造函数
             
              Matrix(int nRow=5 , int nCol=5);
              //矩阵相加
              bool add( Matrix &ma ,Matrix &mb ,Matrix &mc) ;
              //初始化矩阵
              void InitializeMatrix( );//Matrix &ma
 
              //矩阵相减
              void subtraction(Matrix &ma , Matrix &mb ,Matrix &mc) ;
              //矩阵乘法
              void multiplication(Matrix &ma , Matrix &mb ,Matrix &mc) ;
              //获取矩阵的行数 
              int getRow() ;
              //获取矩阵的列数
              int getCol() ;
              //重载符号"<<", 输出矩阵
              friend std::ostream & operator<<(std::ostream &o, Matrix &ma  )//
              {
                   int nRow = ma.getRow() ;
                   int nCol = ma.getCol() ;
	 
                   for(int i = 0 ; i < nRow ; i++)
                   {
                        for(int j = 0; j <nCol ;j++)
                            o << ma.Array[i][j] <<" ";
                        cout<<endl;
                   }
                   return o ;
              }
              //求矩阵均值
              //average(
};
#endif

⌨️ 快捷键说明

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