The Java console prints irregular triangles with the bottom side facing the left

Source: Internet
Author: User

 

/***//**
* Analyzeprimesubmultiple. Java
* Print the case (| the pattern on the right of the line)
* | *
* | ***
* | ******
* | ********
* | ******
* | ***
* | *
* @ Author Deng Chao (codingmouse)
* @ Version 0.1
* Development/test environment: jdk1.6 + eclipse SDK 3.3.2
*/

Public class printrhombusdesign ...{
 
Public static void main (string [] ARGs )...{

/**//*
* Split it into the first four rows and the last three rows for processing,
* Step-by-step output by dividing the fourth behavior triangle line.
*/

// Process the first four rows
For (INT I = 0; I <4; I ++ )...{

// Calculate the output position of the asterisk (first, create the basic shape in ascending odd number)
For (Int J = 0; j <= 2 * I; j ++ )...{

// Special row processing (One asterisk is output from the first row)
If (j = 4 )...{
// Output an asterisk in the console
System. Out. Print ("*");
}
// Output an asterisk in the console
System. Out. Print ("*");
}
// Output an asterisk in the console
System. Out. println ();
}

// Process the last three rows
For (INT I = 0; I <3; I ++ )...{

// Calculate the output position of the asterisk (first, create the basic shape in ascending odd number)
For (Int J = 0; j <5-2 * I; j ++ )...{

// Special row processing (One asterisk is output from the first row)
If (j = 3 )...{
// Output an asterisk in the console
System. Out. Print ("*");
}
// Output an asterisk in the console
System. Out. Print ("*");
}
// Output an asterisk in the console
System. Out. println ();
}
}
}

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.