import java.util.Scanner;
class satutranspose{
public static void main (String[]args){
Scanner in = new Scanner(System.in);
System.out.println("Masukkan Nilai ordo X x Y(ordo harus sama):");
System.out.print("Masukkan Nilai ordo X:");
int x=in.nextInt();
System.out.print("Masukkan Nilai ordo Y:");
int y=in.nextInt();
System.out.println("");
int A[][]=new int [x][y]; // array untuk inputan user
int B[][]=new int [x][y]; //array untuk transpose
int i,j;
System.out.println("========== Masukkan Nilai matrix A ==========");
for(i=0;i<x;i++)
{ System.out.println("");
for(j=0;j<y;j++)
{System.out.print(" A["+i+"]["+j+"]= ");
A[i][j]=in.nextInt();
B[i][j]=0;
}}
System.out.println("");
System.out.println("========== matrix A =========");
for(i=0;i<x;i++)
{
System.out.println("");
for(j=0;j<y;j++)
{
System.out.print(" A["+i+"]["+j+"]= "+A[i][j]);
}
}
System.out.println("");
System.out.println("");
System.out.println("========== Transpose dari matrix A ==============");
for(i=0;i<y;i++)
{System.out.println("");
for(j=0;j<x;j++)
{B[i][j]=A[j][i];
System.out.print(" B["+i+"]["+j+"]= "+B[i][j]);}}
System.out.println("");
System.out.println("");
}
}
Tidak ada komentar:
Posting Komentar