![矩阵构造函数.doc_第1页](http://file.renrendoc.com/FileRoot1/2020-1/9/1dcaff46-722b-4d44-bfd7-f9d153cbb863/1dcaff46-722b-4d44-bfd7-f9d153cbb8631.gif)
![矩阵构造函数.doc_第2页](http://file.renrendoc.com/FileRoot1/2020-1/9/1dcaff46-722b-4d44-bfd7-f9d153cbb863/1dcaff46-722b-4d44-bfd7-f9d153cbb8632.gif)
![矩阵构造函数.doc_第3页](http://file.renrendoc.com/FileRoot1/2020-1/9/1dcaff46-722b-4d44-bfd7-f9d153cbb863/1dcaff46-722b-4d44-bfd7-f9d153cbb8633.gif)
![矩阵构造函数.doc_第4页](http://file.renrendoc.com/FileRoot1/2020-1/9/1dcaff46-722b-4d44-bfd7-f9d153cbb863/1dcaff46-722b-4d44-bfd7-f9d153cbb8634.gif)
![矩阵构造函数.doc_第5页](http://file.renrendoc.com/FileRoot1/2020-1/9/1dcaff46-722b-4d44-bfd7-f9d153cbb863/1dcaff46-722b-4d44-bfd7-f9d153cbb8635.gif)
已阅读5页,还剩2页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
#include using namespace std;class Matrixprivate: int cols,cols1; int *p,*q,*z,*f,*p1,*p2; static int rows;public: /static int rows; Matrix(); / rows=0; / cols=0; / cols1=0; / p=new introws*cols; / p1=new introws*cols; / p2=new introws*cols; / q=new intcols*cols1; / z=new intcols; /f=new introws*cols1; void sr(); void sc(); void sr1(); void sc1(); / Matrix() / / deletep; /deleteq; /deletez; /deletef; /deletep1; /deletep2;/ ;int Matrix:rows=2;Matrix:Matrix() cols=0; cols1=0;void Matrix:sr() p=new introws*cols; p1=new introws*cols; p2=new introws*cols; q=new intcols*cols1; z=new intcols; f=new introws*cols1; cout默认rows=2,pelase enter cols:cols; coutendl; cout请输入矩阵内容:endl; / p=new introws*cols; for(int t=0;tpt; coutplease enter cols1:cols1; cout请输入矩阵内容:endl; / q=new intcols*cols1; /z=new introws*cols1; for(int y=0;yqy; coutendl; int m=0;z0=0;int o=0; for(int i=0;irows;i+) for(int j=0;jcols1;j+) for(int k=0;kcols;k+) m+; zm=zm-1+pi*cols+k*qk*cols1+j; / m+; fo=zm; m=0;z0=0;o+; void Matrix:sc() for(int i=0;irows;i+) coutendl; for(int j=0;jcols1;j+) coutfi*cols1+j ; void Matrix:sr1() cout默认rows=2,pelase enter cols:cols; coutendl; cout请输入第一个矩阵内容:endl; p=new introws*cols; for(int i=0;ipi; cout请输入第二个矩阵的内容:endl; p1=new introws*cols; for(int j=0;jp1j; p2=new introws*cols; for(int i=0;irows*cols;i+) p2i=pi+p1i; void Matrix:sc1() cout矩阵相加结果为:endl; for(int i=0;irows;i+) coutendl; for(int j=0;jcols;j+) coutp2i*cols+j ; int main() Matrix m1; Matrix m2; Matrix m3(m1);/复制构造函数 Matrix m4(m2);/复制构造函数 cout加法请输入1,乘法请输入2:x; switch(x) case 1:m4.sr1(); m4.sc1();break; case 2: m3.sr(); m3.sc();break; default:cout数据库中不存在x数字的功能endl; coutl; return 0;#include using namespace std;class matrixpublic:matrix();matrix(int a,int b);matrix() ;matrix(const matrix &m);int getmatrix();void outputmatrix();matrix(int,int,int*);int lines;int rows;int *p;matrix:matrix(int a,int b) cout构造了一个a行b列矩阵endl; lines=a; rows=b; p=new int*lines; for(int i=0;irows;i+) pi=new introws;matrix:matrix(const matrix &m) cout拷贝了一个m.lines行m.rows列矩阵endl; lines=m.lines; rows=m.rows;p=new int*lines;for(int i=0;irows;i+) pi=new introws;for(int i=0;ilines;i+) for(int j=0;jrows;j+) pij=李特 2014/11/16 19:37:19m.pij;int matrix:getmatrix() cout输入矩阵数据endl;for(int i=0;ilines;i+) for(int j=0;jpij;if(cin) return 1;else cout输入有误endl;cin.good(); return 0; void matrix:outputmatrix() for(int i=0;ilines;i+) for(int j=0;jrows;j+) coutpij ; coutendl; matrix:matrix() for(int i=0;ilines;i+) cout矩阵第i+1行被释放endl; delete pi; matrix operator+(const matrix& mat1,const matrix& mat2) matrix mat3(mat1); for(int i=0;imat1.lines;i+) for(int j=0;jmat1.row李特 2014/11/16 19:37:46s;j+) mat3.pij+=mat2.pij; cout调用+时临时变量将被释放endl; return mat3;matrix operator-(const matrix& mat1,const matrix& mat2) matrix mat3(mat1); for(int i=0;imat1.lines;i+) for(int j=0;jmat1.rows;j+) mat3.pij-=mat2.pij; cout调用+时临时变量将被释放endl; return mat3;int main() int a,b; cout请输入矩阵行数和列数:ab; ma
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 保安工作总结计划安全设备行业保安工作的设备测试
- 企业财务战略与市场策略的协调计划
- 提高学生美术表达能力的策略计划
- 消费者关系管理的工作计划
- 2025年中国休闲食品行业市场运行态势、市场规模及发展趋势研究报告
- 七年级下册《一元一次不等式的解法》课件与练习
- 2025年真空采血管项目发展计划
- 构建稳定异步消息传递框架
- 2025年印铁油墨项目建议书
- 白雪公主的童话世界解读
- 二年级下册数学计算题400道及答案
- 第6课《飞向蓝天的恐龙》两课时学习任务单部编版四年级语文下册
- 生产清场管理制度课件
- 小学科学质量分析报告
- 口腔医院客服培训课件
- 04G325吊车轨道联结及车挡
- 2024年金城出版社有限公司招聘笔试参考题库含答案解析
- 皮下注射的并发症及预防
- 罗沙司他治疗肾性贫血的疗效与安全性评价演示稿件
- 混凝土搅拌站有限空间作业管理制度模版
- 苯板厂应急预案范本
评论
0/150
提交评论