Advertisement
andreisophie

InmultireMatrici

Oct 8th, 2020 (edited)
656
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.05 KB | None | 0 0
  1. using System;
  2. using System.IO;
  3. using System.Linq;
  4. using System.Collections.Generic;
  5.  
  6. namespace CSharp_Shell
  7. {
  8.  
  9.     public static class Program
  10.     {
  11.         public static void Main()
  12.         {
  13.           int[,] a=new int[100,100], b=new int[100,100], c=new int[100,100];
  14.           int n,m,p;
  15.           n= Convert.ToInt32(Console.ReadLine());
  16.           m= Convert.ToInt32(Console.ReadLine());
  17.           p= Convert.ToInt32(Console.ReadLine());
  18.           for (int i=1; i<=n;i++)
  19.             for (int j=1; j<=m; j++)
  20.               a[i,j]= Convert.ToInt32(Console.ReadLine());
  21.           for (int j=1; j<=m;j++)
  22.             for (int k=1; k<=p; k++)    
  23.               b[j,k]= Convert.ToInt32(Console.ReadLine());
  24.           for (int i=1; i<=n; i++)
  25.             for (int j=1; j<=p; j++)
  26.               for (int k=1; k<=m; k++)
  27.                   c[i,j]+=a[i,k]*b[k,j];
  28.           for (int i=1; i<=n; i++)
  29.           {
  30.             for (int j=1; j<=p; j++)
  31.               Console.Write(c[i,j]);
  32.             Console.WriteLine();
  33.           }
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement