using System;
using System.Collections.Generic;
public class Program
{
public static void Main()
{
Console.WriteLine("Hello World");
int i,j,k;
int[,] A = {{1, 2}, {3, 5}, {1,1976}};
int[,] B = {{5, 10, 5}, {100, 1000, 1}};
var ARows = A.GetLength(0);
var ACols = A.GetLength(1);
var BRows = B.GetLength(0);
var BCols = B.GetLength(1);
Console.WriteLine("Numebr of rows in matrix A: " + ARows + " and number of columns in matrix A: " + ACols);
Console.WriteLine("Numebr of rows in matrix B: " + BRows + " and number of columns in matrix B: " + BCols);
int[,] C = new int[ARows, BRows];
List<int> matrixDimA = new List<int>();
List<int> matrixDimB = new List<int>();
Console.WriteLine("Number of matrix A elements are :" + ARows *ACols);
//matrixDimA.Reverse();
Console.WriteLine("Elements of matrix A elements are :");
for (i = 0; i < ARows; i++)
{
Console.Write("[");
for (j = 0; j < ACols; j++)
{
if (j != ACols - 1)
{
Console.Write( A[i, j] + ",");
}
else
{
Console.Write( A[i, j]);
}
}
Console.WriteLine("]");
}
Console.WriteLine("Number of matrix A elements are :" + BRows *BCols);
Console.WriteLine("Elements of matrix A elements are :");
for (i = 0; i < BRows; i++)
{
Console.Write("[");
for (j = 0; j < BCols; j++)
{
if (j != BCols - 1)
{
Console.Write( B[i, j] + ",");
}
else
{
Console.Write( B[i, j]);
}
}
Console.WriteLine("]");
}
if((ARows == BCols) & (ACols == BRows))
{
Console.WriteLine("Matrix multiplication is possible because: ");
Console.WriteLine("Numebr of rows in matrix A: " + ARows + " = with number of columns in matrix B: " + BCols);
Console.WriteLine("Numebr of columns in matrix A: " + ACols + " = with number of rows in matrix B: " + BRows);
for (i = 0; i < ARows; i++)
{
Console.Write("[");
for (j = 0; j < BRows; j++)
{
if (j != ACols - 1)
{
C[i, j] = A[i, j] * B[j, i];
Console.Write( C[i, j] + ",");
}
else
{
C[i, j] = A[i, j] * B[j, i];
Console.Write( C[i, j]);
}
}
Console.WriteLine("]");
}
} else {
Console.WriteLine("Matrix multiplication rows is not possible.");
}
var CRows = C.GetLength(0);
var CCols = C.GetLength(1);
Console.WriteLine("Number of matrix C elements are :" + CRows *CCols);
Console.WriteLine("Elements of matrix C elements are :");
for (i = 0; i < CRows; i++)
{
Console.Write("[");
for (j = 0; j < CCols; j++)
{
if (j != CCols - 1)
{
Console.Write( C[i, j] + ",");
}
else
{
Console.Write( C[i, j]);
}
}
Console.WriteLine("]");
}
}
}