You are on page 1of 2

KARTIK V / 11A / 11122

2.WAPT transpose a DDA and print it. import java.io.* ;


class transpose { InputStreamReader reader=new InputStreamReader(System.in); BufferedReader input=new BufferedReader(reader); String text; int a[][]=new int[3][3]; int b[][]=new int[3][3]; void accept()throws IOException { for(int i=0;i<3;i++) { for(int j=0;j<3;j++) { text=input.readLine(); a[i][j]=Integer.parseInt(text); }}} void transposing() { for(int i=0;i<3;i++) { for(int j=0;j<3;j++) { b[i][j]=a[j][i]; }}} void display1() { System.out.println("ORIGNINAL ARRAY :"); KARTIK V / 11A / 11122

KARTIK V / 11A / 11122 for(int i=0;i<3;i++) { for(int j=0;j<3;j++) { System.out.print(a[i][j]+" "); } System.out.println(); }} void display2() { System.out.println("TRANSPOSE ARRAY :"); for(int i=0;i<3;i++) { for(int j=0;j<3;j++) { System.out.print(b[i][j]+" "); } System.out.println(); }} public static void main()throws IOException { transpose obj=new transpose(); obj.accept(); obj.transposing(); obj.display1(); obj.display2(); }}//end of class OUTPUT :

KARTIK V / 11A / 11122

You might also like