// matrixMulti.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <stdio.h>
#include <iostream>
#define N 4
#define Len 16
void multi(int a[],int b[]){
int i,j,t,k;
//int cLen=N*N;
int c[Len]={0};
for(k=0;k<N*N;k++){
i=k/N;
j=k%N;
for(t=0;t<N;t++)
{
c[k]+=a[N*i+t]*b[j+t*N];
}
printf("%d ",c[k]);
}
}
int main(int argc, char* argv[])
{
int a[]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
int b[]={0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
multi(a,b);
return 0;
}
矩阵相乘 一维数组表示
最新推荐文章于 2021-09-16 16:47:02 发布