Program Penjumlahan Matriks

Listing
import java.io.*;
class transpose1
{
public static void main (String[] args) throws Exception
{
BufferedReader input = new BufferedReader( new InputStreamReader (System.in));




System.out.print("Masukkan Jumlah Ordo matriks n*n = ");
int n=Integer.parseInt(input.readLine());
int [][] matrika = new int [n][n];
int [][] matrikb = new int [n][n];
int [][] matrikc = new int [n][n];

System.out.println("Matriks A : ");
for (int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
System.out.print("elemen ["+(i+1)+","+(j+1)+"] =");
matrika[i][j] = Integer.parseInt(input.readLine());
}
}
System.out.println("Matriks B : ");
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
System.out.print("elemen ["+(i+1)+","+(j+1)+" ] =");
matrikb [i][j]=Integer.parseInt(input.readLine());
}
}
System.out.print("");
for(int i=0;i<n;i++)
{
System.out.print("|");
for(int j=0;j<n;j++)
{
matrikc[i][j]=matrika[i][j]+matrikb[i][j];
System.out.print(matrikc[i][j]+" ");

}
System.out.println("|");

}
System.out.print("]");

}
}


Output



Komentar

Postingan populer dari blog ini

Fixed Point dan Floating Point pada ALU

Pengenalan Teknologi Game dan Artificial Intelligence pada Game || Pengantar Teknologi Game || Tugas I

Program Deret Geometri Java