zoukankan      html  css  js  c++  java
  • 数组的乘积

     1 #include "stdafx.h"
     2 #include <stdio.h>
     3 #include <stdlib.h>
     4 #include <string.h>
     5 
     6 void MATRIX_MULTIPLY(int (*a)[3],int (*b)[4])
     7 {
     8     int i = 0,j = 0,k=0;
     9     int *c[2] = {0};
    10     c[0] = (int*)malloc(sizeof(int)*4);
    11     c[1] = (int*)malloc(sizeof(int)*4);
    12     memset(c[0],0,sizeof(int)*4);
    13     memset(c[1],0,sizeof(int)*4);
    14 
    15     for(i=0;i<2;i++)
    16     {
    17         for(j=0;j<4;j++)
    18         {
    19             for(k=0;k<3;k++)
    20                 c[i][j] += a[i][k]*b[k][j];
    21         
    22         }
    23     }
    24     for(i=0;i<2;i++)
    25     {
    26         for(j=0;j<4;j++)
    27             printf("%d ",c[i][j]);
    28         printf("
    ");
    29     }
    30 }
    31 
    32 int _tmain(int argc, _TCHAR* argv[])
    33 {
    34     int a[2][3] = {{1,2,3},{4,5,6}};
    35     int b[3][4] = {{1,0,8,4},{7,6,4,5},{4,3,2,1}};
    36     MATRIX_MULTIPLY(a,b);
    37     return 0;
    38 }
    View Code
  • 相关阅读:
    oracle 分析函数3
    oracle 分析函数4
    oracle 分析函数2
    postgres
    博客系统
    Java 笔试面试 算法编程篇 一
    Java 笔试面试 基础篇 一
    Struts2
    mysql 数据类型
    ExceptionDemo
  • 原文地址:https://www.cnblogs.com/welsh-android-learning/p/3492334.html
Copyright © 2011-2022 走看看