Showing posts with label Matrix Multiplication in Java. Show all posts
Showing posts with label Matrix Multiplication in Java. Show all posts

Thursday, July 7, 2011

Program for Matrix Multiplication in Java

class ThreeDArray
{
public static void main(String args[ ])
{
int a[][][]={ { {5,0,2}, {0,0,9}, {4,1,0}, {7,7,7}},
                                 { {3,0,0}, {8,5,0}, {0,0,0}, {2,0,9}}
                               };
int count = 0;


for (int i = 0; i < 2; i++)
      for (int j= 0; j < 4; j++)
              for (int k = 0; k < 3; k++)
                                     if (a[i][j][k]==0)    
    ++count;


System.out.println("This Array has "+count+" zeros.");
}
}