Multiplication of two two-dimensional arrays (matrices)

Source: Internet
Author: User

1 //two two-dimensional array multiplication2#include <stdio.h>3#include <stdlib.h>4 #defineM 25 #defineN 36 //#define P 67 voidMain ()8 {9     inti,j,k;Ten     //Two-dimensional arrays A and B are multiplied, and the product is placed in the array C One     intA[m][n],b[n][m],c[m][m]; A     //Enter the value of the element of the two-dimensional array a -printf"Please enter the elements of matrix A:"); -      for(i=0; i<m;i++) the     { -          for(j=0; j<n;j++) -         { -scanf"%d",&a[i][j]); +         } -     } +printf"\ n"); A     //printing elements of a two-dimensional array a atprintf"matrix A is as follows: \ n"); -      for(i=0; i<m;i++) -     { -          for(j=0; j<n;j++) -         { -printf"%3d", A[i][j]); in         } -printf"\ n"); to     } +printf"\ n"); -     //Enter the value of the element for the two-dimensional array b theprintf"Please enter the elements of matrix B:"); *      for(i=0; i<n;i++) $     {Panax Notoginseng          for(j=0; j<m;j++) -         { thescanf"%d",&b[i][j]); +         } A     } theprintf"\ n"); +     //printing elements of a two-dimensional array b -printf"Matrix B is as follows: \ n"); $      for(i=0; i<n;i++) $     { -          for(j=0; j<m;j++) -         { theprintf"%3d", B[i][j]); -         }Wuyiprintf"\ n"); the     } -     //array Multiplication Wuprintf"\ n matrix a multiplied by matrix B results to: \ n"); -      for(i=0; i<m;i++) About     { $          for(j=0; j<m;j++) -         { -C[I][J] =0; -              for(k=0; k<n;k++) AC[I][J] = c[i][j]+a[i][k]*B[k][j]; +         } the     } -printf"\ n"); $     //values in array C are displayed in a branch the      for(i=0; i<m;i++) the     { the          for(j=0; j<m;j++) the         { -printf"%3d", C[i][j]); in         } theprintf"\ n"); the     } AboutSystem"Pause"); the}

Multiplication of two two-dimensional arrays (matrices)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.