JAVA DİLİNDE - Birim matris yapımı

 

 

public class NewMain {

    public static void main(String[] args) {

 //5*5 lik birim mastrisi gösterip ekrana yazan kod....

 int a[][]=new int[5][5];

 for(int i=0;i<=5;i++){

     for(int j=0;j<5;j++){

     if(i==j)//eğer satır sayısı ile sütun sayısı eşit olan yer varsa orayı 1 yap,

        a[i][j]=1;

     else  // değilse 0 yap,

         a[i][j]=0;

      System.out.print(a[i][j]+" ");

     }

     System.out.println();//sütunları birbirinden ayırıyor..

}    }    }





Yorumlar