Given a number N which represents the number of rows. The task is to print a half diamond Number-Star pattern as shown in the below examples.
Note: N is always an even number.
Input: N = 4 Output: 2*2 1 1 2*2 Input: N = 6 Output: 3*3*3 2*2 1 1 2*2 3*3*3
On carefully observing the above pattern, it can be broken down into two different triangles:
- An upside down right angled triangle.
- A normal right angled triangle.
For the first triangle pattern:
- Run two loops, first will take care of the number of rows and other will take care of the ‘*’ and numbers being printed.
- Inside the loops check whether the iterations of inner loop has reached to the given number of rows or not.
- If yes, print only number, otherwise print ‘*’ and number both.
The same approach will be followed for the second triangle pattern with a slight change that here the condition will be checked where the inner iteration is equal to 0 or not.
Below is the implementation of above approach:
3*3*3 2*2 1 1 2*2 3*3*3
- Program to print half Diamond star pattern
- Python Program to print hollow half diamond hash pattern
- Program to print hollow pyramid and diamond pattern
- Program to print numbers with diamond pattern
- Program to print Inverse Diamond pattern
- Program for diamond pattern with different layers
- Program to print the diamond shape
- Python Program to print a number diamond of any given size N in Rangoli Style
- Programs to print Triangle and Diamond patterns using recursion
- Program to print a pattern of numbers
- Python Program to print digit pattern
- Program to print pyramid pattern
- C Program to print pyramid pattern
- Program to print a rectangle pattern
- Program to print interesting pattern
- Program to print number pattern
- Program to print number with star pattern
- Program to print reverse character bridge pattern
- Program to print a inverse pyramid character pattern
- Program to print the pattern 'G'
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.