"Dark Horse Programmer"-java Basic learning-output a hollow diamond

Source: Internet
Author: User

1  Packagetest;2 3 /**4 * content is output a hollow diamond5  * @authorA blind cat meets a dead tiger6  *7  */8 9  Public classlinxing {Ten  One      Public Static voidMain (string[] args) { A         intN=15; - lingxing (n); -  the     } -      -     //outputs a diamond of n rows -      Public Static voidLingxing (intN) { +         //outputs the upper half of the first part -          for(inti=0;i<n;i++) {//Output N Rows +              for(intj=0;j<n+i;j++) {//print N+i characters per line A                  at                 if(j==n+i-1| | J==n-1-i) {//if it is the last character or a symmetrical position, the * number is displayed -System.out.print ("*"); -}Else{ -System.out.print (""); -                 } -                  in             } - System.out.println (); to         } +      -         //output Lower the          for(inti=0;i<n-1;i++) {//Output n-1 Line *              for(intj=0;j<2* (n-1)-i;j++) {//print per line (n-1)-I characters $                 Panax Notoginseng                 if(j==2* (n-1)-i-1| | j==i+1) {//if it is the last character or a symmetrical position, the * number is displayed -System.out.print ("*"); the}Else{ +System.out.print (""); A                 } the                  +             } -              $ System.out.println (); $         } -          -     } the  -     Wuyi  the}

"Dark Horse Programmer"-java Basic learning-output a hollow diamond

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.