1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > 矩阵相乘c语言代码用指针实现 矩阵相乘C语言实现

矩阵相乘c语言代码用指针实现 矩阵相乘C语言实现

时间:2022-12-06 23:10:47

相关推荐

矩阵相乘c语言代码用指针实现 矩阵相乘C语言实现

《矩阵相乘C语言实现》由会员分享,可在线阅读,更多相关《矩阵相乘C语言实现(2页珍藏版)》请在人人文库网上搜索。

1、矩阵相乘C语言实现程序本程序的思想用到了双循环嵌套,以及动态分配内存的知识。#include/ bjk * cki = ajivoid matrix(int *b,int *c, int *a, int nx, int ny, int nk)int i,j,k;for (j=0;jny;j+)for(i=0;inx;i+)aji= 0;for(j=0;jny;j+)for(i=0;inx;i+)for(k=0;knk;k+)aji+= bjk*cki;void main()int i,j,k,tmp;int b_row,b_col;int c_row,c_col;int a_row,a_col。

2、;int *b,*c,*a;printf(please enter b_row b_col of matrix Bn);scanf(%d %d,&b_row,&b_col);c_row = b_col;printf(please enter c_col of matrix Cn);scanf(%d,&c_col);a_row = b_row;a_col = c_col;a = (int *) malloc(sizeof(int *) * a_row);for (j=0;ja_row;j+)aj = (int *) malloc(sizeof(int) * a_col);b = (int *) 。

3、malloc(sizeof(int *) * b_row);for (j=0;jb_row;j+)bj = (int *) malloc(sizeof(int) * b_col);c = (int *) malloc(sizeof(int *) * c_row);for (j=0;jc_row;j+)cj = (int *) malloc(sizeof(int) * c_col);if (!cc_row-1) printf(no enought memoryn);exit(0);printf(Please input int matrix b%d%dn,b_row,b_col);for (j=0;jb_row;j+)for (i=0;ib_col;i+)scanf(%d,&tmp);bji = tmp;printf(Please input int matrix c%d%dn,c_row,c_col);for (j=0;jc_row;j+)for (i=0;ic_col;i+)scanf(%d,&tmp);cji = tmp;matrix( b ,c,a, a_col, a_row, b_col);for(j=0;ja_row;j+)for (i=0;ia_col;i+) printf(%d ,aji);printf(n。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。