资源预览内容
第1页 / 共5页
第2页 / 共5页
第3页 / 共5页
第4页 / 共5页
第5页 / 共5页
亲,该文档总共5页全部预览完了,如果喜欢就下载吧!
资源描述
# include # define MAXSIZE 20 using namespace std;typedef struct/三元组的定义 int row;/非 0 元的行下标 int col;/非 0 元的列下标 int e;/非 0 元的素值Triple;typedef struct/矩阵的定义 Triple dataMAXSIZE;/非 0 元三元组表 int m,n,len;/矩阵的行数,列数和非 0 元个数TSMatrix;void initMatrix(TSMatrix A.m=0; A.n=0; for (int i=0; iA.mA.nA.len;/输入矩阵的行、列值及非 0 元的个数 for(int i=0;iA.datai.row; cinA.datai.col; cinA.datai.e; int search(TSMatrix A,int m,int n)/找到 m 行 n 列元素在 A 的三元组表中的位置。若找到返回值,若找不到返回-1 int flag=-1; for(int i=0;ii; while(true) int i; cini; switch(i) case 0:system(“cls“);cout“创建矩阵 A:“endl;createMatrix(A);/调用创建函数cout“创建矩阵 B:“endl;createMatrix(B);showtip();/调用菜单函数break; case 1:system(“cls“);if(A.m=0|B.m=0)cout“未创建矩阵“endl;elseinitMatrix(C);/调用矩阵初始化函数 mult(A,B,C);/调用矩阵相称函数if(A.n=B.m) cout“乘后的结果:“endl; print(A); cout“*“endl; print(B); cout“=“endl; print(C); /end_if(A.n=B.m)/end_elseshowtip();break; case 2: exit(0); break;/end_switch /end_while/end_main
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号