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

📄 matrix.h

📁 正则表达式由一些普通字符和一些元字符(metacharacters)组成。普通字符包括大小写的字母和数字
💻 H
字号:
#ifndef MATRIX_H
#define MATRIX_H

#include <iostream>
#include <stdlib.h>
#include <conio.h>

using namespace std;

template<typename _Type>
class Matrix
{
public:
	int Row;
	int Column;
	_Type** Data;

	Matrix()
	{
		Row=0;
		Column=0;
	}

	Matrix(const int TempRow, const int TempColumn)
	{
		Row=TempRow;
		Column=TempColumn;
		New();
	}

	Matrix(Matrix<_Type>& Object)
	{
		Row=Object.Row;
		Column=Object.Column;
		New();

		for (int i=0; i<=Row-1; ++i)
			for (int j=0; j<=Column-1; ++j)
				Data[i][j]=Object.Data[i][j];
	}

	~Matrix()
	{
		Release();
	}

	void New()
	{
		for (int i=0; i<=Row-1; ++i)
			Data=new _Type*[Row];
		for (int i=0; i<=Row-1; ++i)
			Data[i]=new _Type[Column];
	}

	void New(const int TempRow, const int TempColumn)
	{
		Row=TempRow;
		Column=TempColumn;
		New();
	}

	void Release()
	{
		for (int i=0; i<=Row-1; ++i)
			delete[] Data[i];
		Data=0;
		Row=0;
		Column=0;
	}

	void Initialize(const _Type& Value)
	{
		for (int i=0; i<=Row-1; ++i)
			for (int j=0; j<=Column-1; ++j)
				Data[i][j]=Value;
	}

	void Copy(Matrix<_Type>& Object)
	{
		Release();
		Row=Object.Row;
		Column=Object.Column;
		New();

		for (int i=0; i<=Row-1; ++i)
			for (int j=0; j<=Column-1; ++j)
				Data[i][j]=Object.Data[i][j];
	}

	_Type& operator()(int x, int y)
	{
		return Data[x][y];
	}

	Matrix<_Type>& operator=(Matrix<_Type>& Object)
	{
		Copy(Object);
		return *this;
	}
};

#endif

⌨️ 快捷键说明

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