The crown star pattern prints three points that grow out of a solid band, like a simple drawn crown. The side points grow from the edges and the middle point grows in both directions.
Quick answer: Use a grid 4n + 1 columns wide. On row i of the top part, put a star where j ≤ i (left point), where j > 4n + 1 − i (right point), or within i − 1 columns of the centre column 2n + 1 (middle point). Then print two full rows for the band.
This program is part of the Tricky Patterns collection.
Table of contents8 sections
Crown Star Pattern output
Output (n = 3):
* * * ** *** ** *** ***** *** ************* *************

How the crown star pattern works
Each point is a simple shape. The left one is a right triangle against the left edge, the right one is its mirror against the right edge, and the middle one is a small pyramid centred on column 2n + 1. All three grow by one row at a time, so one row loop and one combined condition draw them together. The band underneath is a plain block of stars.
- Run the outer loop for
ifrom1ton, one row per pass (the three points). - Go through
4 × n + 1positions in the row. Print stars wherej ≤ i or j > 4 × n + 1 − i or (j > 2 × n + 1 − i and j < 2 × n + 1 + i); print spaces everywhere else. - Move to the next line.
- Run the outer loop for
ifrom1to2, one row per pass (the band). - Print
4 × n + 1stars. - Move to the next line.
Key takeaways
- The crown is three triangles sharing the same rows, plus a solid band.
- The middle point is centred on column
2n + 1, half way across the4n + 1grid. - Combining the three tests with
||lets one grid loop print all of them. - The band is just two rows of
4n + 1stars.
Crown Star Pattern in C
#include <stdio.h>
int main(void) {
int n = 3;
// the three points
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= 4 * n + 1; j++) {
if (j <= i || j > 4 * n + 1 - i || (j > 2 * n + 1 - i && j < 2 * n + 1 + i))
printf("*");
else
printf(" ");
}
printf("\n");
}
// the band
for (int i = 1; i <= 2; i++) {
for (int j = 1; j <= 4 * n + 1; j++)
printf("*");
printf("\n");
}
return 0;
}Crown Star Pattern in C++
#include <iostream>
using namespace std;
int main() {
int n = 3;
// the three points
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= 4 * n + 1; j++) {
if (j <= i || j > 4 * n + 1 - i || (j > 2 * n + 1 - i && j < 2 * n + 1 + i))
cout << "*";
else
cout << " ";
}
cout << endl;
}
// the band
for (int i = 1; i <= 2; i++) {
for (int j = 1; j <= 4 * n + 1; j++)
cout << "*";
cout << endl;
}
return 0;
}Crown Star Pattern in Java
public class CrownStar {
public static void main(String[] args) {
int n = 3;
// the three points
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= 4 * n + 1; j++) {
if (j <= i || j > 4 * n + 1 - i || (j > 2 * n + 1 - i && j < 2 * n + 1 + i))
System.out.print("*");
else
System.out.print(" ");
}
System.out.println();
}
// the band
for (int i = 1; i <= 2; i++) {
for (int j = 1; j <= 4 * n + 1; j++)
System.out.print("*");
System.out.println();
}
}
}Crown Star Pattern in Python
n = 3
# the three points
for i in range(1, n + 1):
for j in range(1, 4 * n + 2):
if j <= i or j > 4 * n + 1 - i or (j > 2 * n + 1 - i and j < 2 * n + 1 + i):
print("*", end="")
else:
print(" ", end="")
print()
# the band
for i in range(1, 3):
for j in range(1, 4 * n + 2):
print("*", end="")
print()Time and space complexity
The program prints one character for each position in the pattern, so for n rows it runs in O(n²) time. It only needs a few loop variables, so the extra memory is O(1).
Frequently asked questions
How do I make the points taller?
Raise n. The grid widens to 4n + 1 columns and each point grows to n rows, so the proportions stay the same.
Can I add more points?
Yes. Each extra point is another centred pyramid in the condition. Spread the centres evenly across a wider grid, for example at 2n + 1 and 6n + 1 on a 8n + 1 grid.
Why does the middle point test use a strict comparison?
j > 2n + 1 − i and j < 2n + 1 + i include 2i − 1 columns, the usual pyramid width. Using ≥ and ≤ would make every row two stars too wide.











