Java_ implements a multiplication table that prints various styles __java

Source: Internet
Author: User

Go from: http://blog.csdn.net/scongzhongxiao/article/details/53052422

public class Multiplicationtable {public static void main (string[] args) {table table=new table ();
        Table.printall ()//Print full 99 multiplication table to "T" mode to align Table.devide ();

        Table.printallalignspace ();//Print full 99 multiplication table to align Table.devide () with space;
        Print the 99 multiplication table Table.printleftuptorightdown () from the upper left corner 1*1 to the lower right corner.
        Table.devide ();
        Print 99 multiplication Table 2 Table.printleftuptorightdown2 () from upper left corner 1*1 to lower right corner;
        Table.devide ();
        From the lower left corner of the 1*1 a column begins to print the 99 multiplication table Table.printleftdowntorightup ();
        Table.devide ();
        From the lower left corner of the 1*1 a column begins to print to the upper right corner of the 99 multiplication table 2 table.printleftdowntorightup2 ();
        Table.devide ();
        Print a 99 multiplication table Table.printleft9torightdown () from the top left corner of the 9*9 to the lower right corner.
        Table.devide ();
        Print 99 multiplication Table 2 Table.printleft9torightdown2 () from the top left corner of the 9*9 to the lower right corner.
        Table.devide ();
        Start with a 9*9 in the lower-left corner to print the 99 multiplication table Table.printleft9downtorightup () in the upper-right corner;
        Table.devide (); Start with a 9*9 in the lower left corner to print 99 multiplication table 2 in the upper right corner table.prIntleft9downtorightup2 ();
        The class table{//Print full 99 multiplication table aligns the public void printall () {int i,j with "\ t" mode;
            for (i=1;i<=9;i++) {for (j=1;j<=9;j++) {System.out.print (j+ "*" +i+ "=" +i*j+ "\ t");
        } System.out.println ();
        The full 99 multiplication table is aligned to the public void Printallalignspace () {int i,j; for (i=1;i<=9;i++) {for (j=1;j<=9;j++) if (i*j>9) {System.out.print (
                j+ "*" +i+ "=" +i*j+ "");
                else {System.out.print (j+ "*" +i+ "=" +i*j+ ");
        } System.out.println ();
        From the top left corner to the lower right corner print 99 multiplication table public void Printleftuptorightdown () {int i,j; for (i=1;i<=9;i++) {for (j=1;j<=9;j++) {if (j>=i) {System.out.print (
                j+ "*" +i+ "=" +i*j+ "T");
            } else{        if (i*j<=9| |
                    I&GT;J) {System.out.print ("");
                    } else{System.out.print ("");
        }} System.out.println ();
        From the top left corner to the lower right corner print 99 multiplication table public void printLeftUpToRightDown2 () {int i,j; for (i=1;i<=9;i++) {for (j=1;j<=9;j++) {if (j<=i) {System.out.print (
                j+ "*" +i+ "=" +i*j+ "T");
                } else{System.out.print ("");
        } System.out.println ();
        A column from the lower-left corner of the 1*1 begins to print to the upper-right corner of the 99 multiplication table public void Printleftdowntorightup () {int i,j;         for (i=9;i>=0;i--) {for (j=1;j<=9;j++) {if (i<j) {System.out.print ("
                "); } else{if (i*j>9) {System.out.print (j+ "*" +i+ "=" +i*j+ ");
                    } else{System.out.print (j+ "*" +i+ "=" +i*j+ ");
        }} System.out.println ();
        A column from the lower-left corner of the 1*1 begins to print to the upper-right corner of the 99 multiplication table public void printLeftDownToRightUp2 () {int i,j; for (i=9;i>=1;i--) {for (j=1;j<=9;j++) {if (i>j) {System.out.print (
                "        ");
                    } else{if (i*j>9) {System.out.print (j+ "*" +i+ "=" +i*j+ ");
                    } else{System.out.print (j+ "*" +i+ "=" +i*j+ ");
        }} System.out.println ();
        }///From a column in the upper-left corner of the 9*9 start to the lower right corner print 99 multiplication table public void Printleft9torightdown () {int i,j;
  for (i=9;i>=1;i--) {          for (j=9;j>=1;j--) {if (i>j) {System.out.print ("");
                else {System.out.print (j+ "*" +i+ "=" +i*j+ "T");
        } System.out.println ();
        }///From a column in the upper-left corner of the 9*9 start to the lower right corner print 99 multiplication table 2 public void printleft9torightdown2 () {int i,j;         for (i=9;i>=1;i--) {for (j=9;j>=1;j--) {if (i<j) {System.out.print ("
                ");
                else {System.out.print (j+ "*" +i+ "=" +i*j+ "T");
        } System.out.println ();
        }//From the lower left corner of a 9*9 start to the upper right corner print 99 multiplication table public void Printleft9downtorightup () {int i,j;        for (i=1;i<10;i++) {for (j=9;j>0;j--) {if (i<j) {System.out.print ("
                "); else {System.ouT.print (j+ "*" +i+ "=" +i*j+ "T");
        } System.out.println ();
        A 9*9 from the lower left corner begins to print to the upper right corner 99 multiplication table 2 public void printleft9downtorightup2 () {int i,j; for (i=1;i<10;i++) {for (j=9;j>0;j--) {if (j<i) {System.out.print ("\
                T ");
                else {System.out.print (j+ "*" +i+ "=" +i*j+ "T");
        } System.out.println (); }} public void Devide () {System.out.println ("-----------------------------------------------------------
    ------------");
 }

}

The effect is as follows


Keywords: Java printing; multiplication table; Output

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.