Java Learning Notes (iv)---print graphics

Source: Internet
Author: User

1   //1. Diamond2    Public Static voidLingxing (intsize) {3     if(size% 2 = = 0){4size++;//Calculate Diamond Size5     }6     //top half of the output diamond7      for(inti = 0; I < SIZE/2 + 1; i++) {8        for(intj = size/2 + 1; J > i + 1; j--) {9System.out.print ("");//white space at the top left corner of the outputTen       } One        for(intj = 0; J < 2*i + 1; J + +) { ASystem.out.print ("*");//top half of the output diamond -       } -System.out.println ();//line Break the     } -     //output diamond Lower half -      for(inti = SIZE/2 + 1; i < size; i++) { -        for(intj = 0; J < I-SIZE/2; J + +) { +System.out.print ("");//output diamond lower left corner blank -       } +        for(intj = 0; J < 2*size-1-2*i; J + +) { ASystem.out.print ("*");//output diamond Lower half at       } - System.out.println (); -     } -   } -  -   //2.99 Multiplication Table in    Public Static voidmultiplicationtable () { -      for(inti = 1; I <= 9; i++) { to        for(intj = 1; J <= I; J + +) { +System.out.print (j+ "x" +i+ "=" +i*j+ "\ t");//\ t jumps to the next tab position -       } theSystem.out.println (""); *     } $   }Panax Notoginseng  -   //3. Printing triangles the    Public Static voidTriangle (intN) { +      for(inti = 0; I <= N; i++) { A        for(intj = N; J >= I; j--) { theSystem.out.print ("");//set up number 1th graphics +       } -        for(intj = 1; J <= I; J + +) { $System.out.print ("*");//set up number 2nd graphics $       } -        for(intj = 1; J < I; J + +) { -System.out.print ("*");//set up number 3rd graphics the       } -System.out.println ("");Wuyi     } the   } -  Wu   //4. Print inverted triangles -    Public Static voidInvertedtriangle (inti) { About     //Print a inverted triangle $      for(intm = 1; M <= i; m++) { -        //Print Space -         for(intn = 0; n <= m; n++) { -System.out.print (""); A        } +        //Print * the         for(intx = 1; x <= (I-M) + 1; X + +) { -System.out.print ("*"); $        } the System.out.println (); the     }   the   } the    -   //5. Print Parallelogram in    Public Static voidParallelogram (intN) { the     //The outer loop each time a * the      for(inti = 1; I <=n; i++) { About       //padding Spaces the        for(intj = 1; J <= N-i; J + +) { theSystem.out.print (""); the       } +       //The inner loop prints one at a time * -        for(intK = 1; K <=n; k++) { theSystem.out.print ("*");Bayi       } the System.out.println (); the     } -   } -  the   //6. Print Parallelogram the    Public Static voidRectangle (intN) { the     //The outer loop each time a * the      for(inti = 1; I <=n; i++) { -       //Outer loop output one line at a time * theSystem.out.print ("*"); the  the       //The inner loop prints one at a time *94        for(intK = 1; K <=n; k++) { theSystem.out.print ("*"); the       } the System.out.println ();98     } About}

Java Learning Notes (iv)---print graphics

Related Article

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.