zoukankan      html  css  js  c++  java
  • 【NO.3】 c program to caculate and display sum of two matrix

    source code:

    #include "stdafx.h"

    /* display sum of two matrix*/

    int _tmain(int argc, _TCHAR* argv[])
    {
     int a[3][3], b[3][3], c[3][3], i, j;
     i = j = 0;
     printf("input elements into the first matrix a[3][3] ");
     for (i = 0; i < 3; i++)
     {
      for(j = 0; j < 3; j++)
      {
       scanf_s("%d", &a[i][j]);
      }
     }
     printf("input elements into the first matrix b[3][3] ");
     for (i = 0; i < 3; i++)
     {
      for(j = 0; j < 3; j++)
      {
       scanf_s("%d", &b[i][j]);
      }
     }

     for (i = 0; i < 3; i++)
     {
      for(j = 0; j < 3; j++)
      {
       c[i][j] = a[i][j]+b[i][j];
      }
     }
     printf("the sum of the two matrix is below: ");
     for (i = 0; i < 3; i++)

     {  
      for(j=0;j<3;j++)  
      {
       printf("%d ",c[i][j]);   
      }
      printf("
    "); 
     }
     getchar();
    }
    
    
    inputs and outputs:
    
        
            

    版权声明:本文博主原创文章,博客,未经同意不得转载。

  • 相关阅读:
    java面试总结之框架问题
    数据库设计三大范式
    js 一些技巧
    el 和 fmt 常用
    iframe自适应高度
    MySQL基础
    任意精度整数算法 (BigInteger) 和任意精度小数算法 (BigDecimal)
    hibernate
    Struts2
    Servlet、Cookie、Session
  • 原文地址:https://www.cnblogs.com/blfshiye/p/4844437.html
Copyright © 2011-2022 走看看