/*
  矩阵相乘
*/
#include 
"stdio.h"
#include 
"conio.h"

#define row 2
#define col 3

main()
{

    
int c[row][row]={0};
    
int a[row][col]={
                        {
1,2,3},
                        {
4,5,6}
                    };
    
int b[col][row]={
                        {
1,2},
                        {
3,4},
                        {
5,6}
                    };
    
    
int i,j,k;

    
for(i=0;i<row;i++)
    {
       
for(j=0;j<row;j++)
       {
           c[i][j]
=0;

           
for(k=0;k<col;k++)
           {
               c[i][j]
+=a[i][k]*b[k][j];
           }

       }
    }

    output(a,row,col);
    output(b,col,row);
    output(c,row,row);
    
    getch();
}


output(
int *arr,int _row,int _col)
{
    
int i=0;
    
while(i<_row*_col)
    {
        
if(i%_col==0)printf("\n");
        printf(
"%d ",*(arr+i));

        i
++;
    }
    printf(
"\n==================\n");
}

相关文章:

  • 2021-08-31
  • 2021-11-30
  • 2021-09-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-03
猜你喜欢
  • 2021-10-29
  • 2021-12-06
  • 2021-04-25
相关资源
相似解决方案