Advertisement
VictoriaLodochkina

multiple matrix

Sep 27th, 2021
1,380
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.82 KB | None | 0 0
  1. using System;
  2.  
  3. class Program {
  4.     static double[,] matr3_mul(double[,] mas1, double[,] mas2)
  5.         {
  6.             double[,] res = new double[3, 3];
  7.             for (int i=0; i<3; i++) //строки
  8.             {
  9.                 for (int j=0; j<3; j++) //столбцы
  10.                 {
  11.                     res[i, j] = mas1[i, 0] * mas2[0, j] + mas1[i, 1] * mas2[1, j] + mas1[i, 2] * mas2[2, j];
  12.                 }
  13.             }
  14.             return res;
  15.         }
  16.     static void Main(string[] args) {
  17.         double[,] mas1={
  18.             {5, 8, -4},
  19.             {6, 9, -5},
  20.             {4, 7, -3}
  21.         };
  22.         double[,] mas2={
  23.             {3, 2, 5},
  24.             {4, -1, 3},
  25.             {9, 6, 5}
  26.         };
  27.     double[,] res=matr3_mul(mas1, mas2);
  28.         for (int i=0; i<3; i++){
  29.             for (int j=0; j<3; j++){
  30.                 Console.Write(res[i, j]+" ");
  31.             }
  32.         Console.WriteLine();
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement