1, write the Java program, the two-dimensional array of rows and columns in the cross-tune display. Such as:
1 2 3 The results shown are: 1 4 7
4 5 6 2 5 8
7 8 9 3 6 9
Packagesix; Public classSixoneegiht { Public Static voidMain (string[] args) {intarr[][]=New int[][]{{1,2,3},{4,5,6},{7,8,9}}; System.out.println ("Original two-dimensional array:"); for(inti=0;i<arr.length;i++){ for(intj=0;j<arr[i].length;j++) {//traversing a one-dimensional arraySystem.out.print ("\ T" +Arr[i][j]); } System.out.println (); } System.out.println ("Two-dimensional array after intermodulation:"); for(inti=0;i<arr.length;i++){ for(intj=0;j<arr[i].length;j++) {//traversing a one-dimensional array//int temp; //Temp=arr[i][j]; //arr[j][i]=temp;System.out.print ("\ T" +Arr[j][i]); } System.out.println (); } }}
The results of the operation are as follows:
If the commented out program is displayed:
Packagesix; Public classSixoneegiht { Public Static voidMain (string[] args) {intarr[][]=New int[][]{{1,2,3},{4,5,6},{7,8,9}}; System.out.println ("Original two-dimensional array:"); for(inti=0;i<arr.length;i++){ for(intj=0;j<arr[i].length;j++) {//traversing a one-dimensional arraySystem.out.print ("\ T" +Arr[i][j]); } System.out.println (); } System.out.println ("Two-dimensional array after intermodulation:"); for(inti=0;i<arr.length;i++){ for(intj=0;j<arr[i].length;j++) {//traversing a one-dimensional array int temp; TEMP=ARR[I][J]; arr[j][i]= temp; System.out.print ("\ T" +Arr[j][i]); } System.out.println (); } }}
The results of the operation are as follows:
6th array Two-dimensional array intermodulation rows and columns