Demo

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

using System;

class matrix
{
int[,] x=new int[2,2];
public void input()
{
for(int i=0;i<2;i++)
{
for(int j=0;j<2;j++)
{
Console.WriteLine( ,i,j);
x[i,j]=int.Parse(Console.ReadLine());
}
}
}

public static matrix operator +(matrix a,matrix b)


{
matrix c=new matrix();
for(int i=0;i<2;i++)
{
for(int j=0;j<2;j++)
{
c.x[i,j]=a.x[i,j]+b.x[i,j];
}
}
return(c);

public static matrix operator -(matrix a,matrix b)


{
matrix c1=new matrix();
for(int i=0;i<2;i++)
{
for(int j=0;j<2;j++)
{
c1.x[i,j]=a.x[i,j]-b.x[i,j];
}
}
return(c1);

public void disp()


{
for(int i=0;i<2;i++)
{
for(int j=0;j<2;j++)
{
Console.Write(x[i,j]+ );
}
Console.WriteLine();
}
}

public static void Main()


{
matrix a=new matrix();
matrix b=new matrix();
Console.WriteLine( );
a.input();
Console.WriteLine( );
b.input();
matrix c2=a+b;
Console.WriteLine( );
c2.disp();
matrix c3=a-b;
Console.WriteLine( );
c3.disp();

You might also like