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

📄 matdemo.cpp

📁 C++&datastructure书籍源码,以前外教提供现在与大家共享
💻 CPP
字号:
#include <iostream>#include <string>#include <iomanip>     // for setwusing namespace std;#include "tmatrix.h"// demonstrate class tmatrixtemplate <class T>void Print(const tmatrix<T>& mat){    int j,k;    int rows = mat.numrows(), cols = mat.numcols();    for(j=0; j < rows; j++)    {   for(k=0; k < cols; k++)        {   cout << setw(4) << mat[j][k];        }        cout << endl;    }}int main(){    int rows, cols,j,k;    cout << "row col dimensions: ";    cin >> rows >> cols;        tmatrix<int> mat(rows,cols);    for(j=0; j < rows; j++)              // fill matrix    {   for(k=0; k < cols; k++)        {   mat[j][k] = (j+1)*(k+1);        }    }    Print(mat);    return 0;    }

⌨️ 快捷键说明

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