6th array Two-dimensional array intermodulation rows and columns

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.