LA Buat Rabu 25 November

LISTING PERTAMA 

class array1
{
 public static void main(String[] args)
 {
  int matrix [][] = new int [3][3];
  matrix [0][0] = 1;
  matrix [0][1] = 2;
  matrix [0][2] = 3;
  matrix [1][0] = 4;
  matrix [1][1] = 5;
  matrix [1][2] = 6;
  matrix [2][0] = 7;
  matrix [2][1] = 8;
  matrix [2][2] = 9;
  for (int i=0;i<=2 ;i++ )
  {
   for (int j=0;j<=2 ;j++ )
  {
    System.out.print (matrix [i][j] + " ");
  }
    System.out.println (" ");
  }
 }
}



LISTING KEDUA



class array2


{
 public static void main(String[] args)
 {
  int matrix [][] = new int [3][3];
  matrix [0][0] = 1;
  matrix [0][1] = 2;
  matrix [0][2] = 3;
  matrix [1][0] = 4;
 

 matrix [1][1] = 5;
  matrix [1][2] = 6;
  matrix [2][0] = 7;
  matrix [2][1] = 8;
  matrix [2][2] = 9;
  for (int i=0;i<=2 ;i++ )
  {
   for (int j=0;j<=2 ;j++ )
  {
    System.out.print (matrix [i][j] + " ");
  }
    System.out.println (" ");
  }




  System.out.println (" ");
  int matrix2 [][] = new int [3][3];
  matrix2 [0][0] = 10;
  matrix2 [0][1] = 11;
  matrix2 [0][2] = 12;
  matrix2 [1][0] = 13;
  matrix2 [1][1] = 14;
  matrix2 [1][2] = 15;
  matrix2 [2][0] = 16;
  matrix2 [2][1] = 17;
  matrix2 [2][2] = 18;
  for (int a=0;a<=2 ;a++ )
  {
   for (int b=0;b<=2 ;b++ )
  {
    System.out.print (matrix2 [a][b] + " ");
  }
    System.out.println (" ");
 }
}
}


posted under |

0 comments:

Post a Comment

Newer Post Older Post Home

You can replace this text by going to "Layout" and then "Page Elements" section. Edit " About "

Followers


Recent Comments