中国地质大学实习报告

中国地质大学实习报告

ID:23153609

大小:76.00 KB

页数:11页

时间:2018-11-04

中国地质大学实习报告_第1页
中国地质大学实习报告_第2页
中国地质大学实习报告_第3页
中国地质大学实习报告_第4页
中国地质大学实习报告_第5页
中国地质大学实习报告_第6页
中国地质大学实习报告_第7页
中国地质大学实习报告_第8页
中国地质大学实习报告_第9页
中国地质大学实习报告_第10页
资源描述:

《中国地质大学实习报告》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库

1、中国地质大学实习报告中国地质大学C++上机实习报告PracticeReportforTheC++ProgramminglanguageC++CourseReportCandidate:StudentNumber:Major:C++Supervisor:echanicsandElectronicInformation矩阵的操作一、设计要求(实现以下功能)要求用c++实现:矩阵的创建,输出,复制,转置,加法,减法,乘以一个数,通过行列坐标设置和获取矩阵该位置元素的值。//三个重载函数MatrixCreateMat(introp;mat);//矩阵的输出voidCopyMat(cons

2、tMatrixsource,Matrixtarget);//把矩阵source复制到矩阵targetMatrixTransMat(constMatrixmat);//矩阵的转置MatrixAddMat(constMatrixmat1,constMatrixmat2);//矩阵的加法MatrixSubMat(constMatrixmat1,constMatrixmat2);//矩阵的减法MatrixMulMat(constMatrixmat,intscalar);//矩阵的数乘intGetMatValue(constMatrixmat,introp;mat,introp;m);//

3、释放矩阵元素的空间二、算法分析1.建立结构体structMatrix{intro;m.ro.cols=cols;m.data=ne;}MatrixCreateMat(intro;m.ro.cols=cols(转载于:.botH.data=ne.data[i]=scalar;returnm;}MatrixCreateMat(intro;m.ro.cols=cols;m.data=ne.data[i]=data[i];returnm;}⑵矩阵的输出voidOutputMat(constMatrixmat)//矩阵的输出{for(inti=0;i<mat.roat.cols;j+

4、+)cout<<mat.data[i*mat.cols+j]<<;cout<<endl;}}⑶矩阵的复制voidCopyMat(constMatrixsource,Matrixtarget)//把矩阵source复制到矩阵target{if(target.data==NULL){target.rop;mat)//矩阵的转置{Matrixm;m.roat.cols;m.cols=mat.ro.data=neat.roat.cols];inti,j;for(i=0;i<mat.roat.cols;j++)m.data[i*mat.roat.d

5、ata[j*mat.cols+i];}returnm;}⑸矩阵的加法MatrixAddMat(constMatrixmat1,constMatrixmat2)//矩阵的加法{Matrixm;m.roat1.cols;m.cols=mat1.ro.data=neat1.roat1.cols];for(inti=0;i<mat1.roat1.cols;i++)m.data[i]=mat1.data[i]+mat2.data[i];returnm;}⑹矩阵的减法MatrixSubMat(constMatrixmat1,constMatrixmat2)//矩阵的减法{Matrixm

6、;}m.cols=mat1.ro.data=neat1.roat1.cols];if((mat1.roat2.roat1.cols!=mat2.cols))exit(1);else{for(inti=0;i<mat1.roat1.cols;i++)m.data[i]=mat1.data[i]-mat2.data[i];}returnm;⑺矩阵的数乘MatrixMulMat(constMatrixmat,intscalar)//矩阵的数乘{Matrixm;m.roat.cols;m.cols=mat.ro.data=neat.roat.cols];for(inti=0;i&l

7、t;mat.roat.cols;i++)m.data[i]=mat.data[i]*scalar;returnm;}⑻获取指定行列的元素值intGetMatValue(constMatrixmat,introat.data[roat.cols+col];}⑼将指定行列的元素赋值intSetMatValue(Matrixmat,introat.data[roat.cols+col]=scalar;returnmat.data[roat.cols+col];}⑽释放元素空间voidR

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。