Print triangle Scala PST kill Java

Source: Internet
Author: User

Java code

  Public classTriangle {/**      * @paramargs*/             Public Static voidMain (string[] args) {a ();//Print positive isosceles triangleb ();//Print inverted isosceles triangleC ();//print straight edge on left upright angle triangleD ();//Print straight edge on right angle triangleE ();//print straight edge on left inverted right angle trianglef ();//Print straight Edge right inverted triangleg ();//print bottom left obtuse angle triangleH ();//Print bottom Right angle triangle    }      /*** Function: Print positive isosceles triangle*/       Public Static voidA () {System.out.println ("Print positive isosceles triangle"); intI, J;  for(i=1;i<=5;i++){               for(j=5;j>i;j--) {System.out.print (" "); }               for(j=0;j<i*2-1;j++) {System.out.print ("*");          } System.out.println (); }      }            /*** Print inverted isosceles triangle*/       Public Static voidB () {System.out.println ("Print inverted isosceles triangle"); intI, J;  for(i=1;i<=5;i++){               for(j=1;j<i;j++) {System.out.print (" "); }               for(j=10;j>i*2-1;j--) {System.out.print ("*");          } System.out.println (); }      }      /*** Print straight edge on left upright angle triangle*/       Public Static voidC () {System.out.println ("Print straight edge on left upright angle triangle"); intI, J;  for(i=1;i<=5;i++){               for(j=0;j<i;j++) {System.out.print ("*");          } System.out.println (); }      }            /*** Print straight edge on right angle triangle*/       Public Static voidd () {System.out.println ("Print straight edge on right angle triangle"); intI, J;  for(i=1;i<=5;i++){               for(j=5;j>i;j--) {System.out.print (" "); }               for(j=0;j<i;j++) {System.out.print ("*");          } System.out.println (); }      }      /*** Print straight edge on left inverted right angle triangle*/       Public Static voide () {System.out.println ("Print straight edge on left inverted triangle"); intI, J;  for(i=1;i<=5;i++){               for(j=5;j>=i;j--) {System.out.print ("*");          } System.out.println (); }      }      /*** Print straight edge right inverted triangle*/       Public Static voidf () {System.out.println ("Print straight Edge right inverted triangle"); intI, J;  for(i=1;i<=5;i++){               for(j=1;j<i;j++) {System.out.print (" "); }               for(j=5;j>=i;j--) {System.out.print ("*");          } System.out.println (); }      }      /*** Print bottom left obtuse angle triangle*/       Public Static voidg () {System.out.println ("Print bottom left obtuse angle triangle"); intI, J;  for(i=1;i<=5;i++){               for(j=0;j<i;j++) {System.out.print ("*");          } System.out.println (); }           for(i=1;i<5;i++){               for(j=5;j>i;j--) {System.out.print ("*");          } System.out.println (); }      }      /*** Print bottom right angle triangle*/       Public Static voidh () {System.out.print ("Print bottom Right angle triangle"); inti,j;  for(i=0;i<=5;i++){               for(j=5;j>i;j--) {System.out.print (" "); }               for(j=0;j<i;j++) {System.out.print ("*");          } System.out.println (); }           for(i=1;i<5;i++){               for(j=0;j<i;j++) {System.out.print (" "); }               for(j=5;j>i;j--) {System.out.print ("*");          } System.out.println (); }      }  }  
View Code

Scala code

(1 to 9). Filter (_% 2! = 0). Map ((x) + =" "* ((9-x)/2) +"*"*x). foreach (println _) println (1 to 9). Reverse.filter (_% 2! = 0). Map ((x) + =" "* ((9-x)/2) +"*"*x). foreach (println _) println (1 to 9). Filter (_% 2! = 0). Map ("*"*_). foreach (println _) println (1 to 9). Filter (_% 2! = 0). Reverse.map ("*"*_). foreach (println _)*   ***  ***** ************************* *******  *****   ***    ***************************************************
View Code

Print triangle Scala PST kill Java

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.