forked from badal74/java-codes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQuestion34.java
More file actions
31 lines (30 loc) · 756 Bytes
/
Copy pathQuestion34.java
File metadata and controls
31 lines (30 loc) · 756 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
public class Question34 {
public static void main(String[] args) {
int n=3;
int arr[][]={ {1,2,3},
{1,2,3},
{1,2,3}
};
System.out.println("Before Transpose");
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
System.out.print(arr[i][j]+" ");
}
System.out.println();
}
for(int i=0;i<n;i++){
for(int j=i+1;j<n;j++){
int temp=arr[i][j];
arr[i][j]=arr[j][i];
arr[j][i]=temp;
}
}
System.out.println("After Transpose");
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
System.out.print(arr[i][j]+" ");
}
System.out.println();
}
}
}