For döngüsü ve dizi kullanarak bir matris(toplama işlemi ) kodu yapın. (Yandaki resmi yap işte.)
MATRİS: Toplanabilir veya çarpılabilir soyut miktarlar tablosudur
MATRİS: Toplanabilir veya çarpılabilir soyut miktarlar tablosudur
Kod:
import java.util.Scanner;
public class okann {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) {
int o,k,a,N;
Scanner tık = new Scanner (System.in);
System.out.println("Matrislerin boyutunu girin:");
N = tık.nextInt();
int F[] [] =new int [N] [N] ;
int G[] [] =new int [N] [N];
int Ğ[] [] =new int [N] [N] ;
System.out.println("İstediğiniz A Matrisi Olsun");
System.out.println("------");
for (o= 0; o < N; o++) {
for(k=0;k<N;k++){
System.out.print("A("+o+","+k+")=");
F[o][k]=tık.nextInt();
}
}
System.out.println("Buyrun B Matrisi");
System.out.println("------");
for (o= 0; o < N; o++) {
for(k=0;k<N;k++){
System.out.print("B("+o+","+k+")=");
G[o][k]=tık.nextInt();
}
}
System.out.println("İşte Matrislerin Toplamı");
System.out.println("-----------");
for(o=0;o<N;o++){
for(k=0;k<N;k++){
Ğ[o][k]=0;
for(a=0;a<N;a++) {
Ğ[o][k]+=F[o][a]+G[a][k];}
System.out.print(Ğ[o][k]+" ");
}
System.out.println();
}
}
}