Metrix Operation In Java


class MetrixOperation
{
int A[][]={{1,0,0},{1,1,0},{0,1,1}};
int B[][]={{1,1,1},{0,1,0},{0,0,1}};
int C[][]=new int[3][3];
void printArrayA()
{
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
System.out.print(A[i][j]+" ");
System.out.println();
}
}
void printArrayB()
{
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
System.out.print(B[i][j]+" ");
System.out.println();
}
}
void printXORArray()
{
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
System.out.print(C[i][j]+" ");
System.out.println();
}
}
void XOROperation()
{
for(int i=0;i<3;i++)
{
for(int j=0;j<3;j++)
{
if(A[i][j]==B[i][j])
C[i][j]=0;
else
C[i][j]=1;
}
}
}
public static void main(String args[])
{
MetrixOperation m=new MetrixOperation();
m.XOROperation();
System.out.println("\t"+"Metrix A :");
m.printArrayA();
System.out.println("*******************************");
System.out.println("\t"+"Metrix B :");
m.printArrayB();
System.out.println("*******************************");
System.out.println("\t"+"Metrix A XOR Metrix B:");
m.printXORArray();
}
}

Comments

Popular posts from this blog

GL_QUAD_STRIP Example In OpenGl

GL_POLYGON Example In OpenGl