Shape Rule
Left | stars | right
Each row: A..end, then even stars, then end..A.

Build rows that mirror letters from both ends, while * fills the center gap as the letter half shortens. For top = 'E', the output begins with ABCDEEDCBA and ends with A********A. Includes a live preview, worked C# examples, edge cases, and complexity.
Left | stars | right
Each row: A..end, then even stars, then end..A.
End letter countdown
for (char i = top; i >= 'A'; i--) picks the letter half end.
Prefix, gap, mirror
Print left letters, 2*(top-i) stars, then mirrored letters.
2n chars / row
Every row stays the same length as letters shrink and stars grow.
1–13 rows
Pick a row count and draw the symmetric star-center pattern in the browser.
Complexity
n rows × 2n chars = O(n²); extra memory stays O(1).
A symmetric alphabet pattern with a star center keeps a fixed row width while swapping letter space for stars. The left half shrinks from A..top toward A, the center grows with an even number of * characters, and the right half mirrors the left.
In C# you usually solve it with an outer countdown plus three inner loops (or a string shortcut for the stars): left letters, stars, then mirrored letters, then Console.WriteLine().
It is a classic multi-part row exercise: prefix, gap, and mirror. Once that clicks, hollow diamonds, butterfly patterns, and other fixed-width symmetric shapes become much easier.
Left letters, center stars, right mirror.
Stars = 2*(top - i) — always even.
Every row has exactly 2n characters.
First row doubles the peak letter when stars = 0.
In short: for each end letter i from top down to A, print A..i, then 2*(top-i) stars, then i..A, then break the line.
Given a positive integer rows (or a fixed top letter like 'E'), print a fixed-width symmetric pattern of alphabet halves with a growing star center.
// First 5 rows (conceptual shape)
// ABCDEEDCBA
// ABCD**DCBA
// ABC****CBA
// AB******BA
// A********A | Item | Type | Description |
|---|---|---|
rows | int | Number of lines (typically 1–26). Top letter = 'A' + rows - 1. |
| Printed output | text | Each row has width 2*rows: left letters + even stars + mirrored letters. |
top = 'A' + rows - 1
for i from top down to 'A':
print letters A..i
print 2*(top - i) stars
print letters i..A
print newline | Approach | Idea | Best for |
|---|---|---|
| Three nested loops | Left + stars + right explicitly | Learning and interviews |
new string('*', stars) | Build the gap in one call | Shorter production-style demos |
| Goal | Pattern |
|---|---|
| Walk row ends | for (char i = top; i >= 'A'; i--) |
| Left half | for (char j = 'A'; j <= i; j++) Console.Write(j); |
| Star gap | int stars = 2 * (top - i); |
| Right half | for (char m = i; m >= 'A'; m--) Console.Write(m); |
| Star shortcut | Console.Write(new string('*', stars)); |
| End the row | Console.WriteLine(); |
Same row — three roles that must stay in order.
A..iAscending prefix for this row’s end letter
2*(top-i)Even gap that grows as letters shrink
i..ADescending mirror of the left half
new lineOnly after all three parts finish
Reach for this shape when practicing multi-part fixed-width rows.
Combine ascending, descending, and fill in one row.
Same idea as hollow stars: letters shrink, filler grows.
Visual test that left and right halves stay mirrors.
Next: centered alphabet pyramids with leading spaces.
This is a console teaching pattern — not how you build modern app screens.
Key benefit: one program that locks in prefix + gap + mirror thinking while keeping row width constant.
Choose a row count between 1 and 13 and draw the symmetric alphabet / star-center pattern in the browser.
Three complete C# programs — fixed top letter, console input, and a new string star shortcut. Click View Output to reveal sample console results.
Print five rows with three explicit inner loops.
top = 'E'Hard-coded height — ideal for first demos and screenshots.
using System;
namespace MyApp
{
class Program
{
static void Main(string[] args)
{
char top = 'E';
for (char i = top; i >= 'A'; i--)
{
for (char j = 'A'; j <= i; j++)
{
Console.Write(j);
}
int stars = 2 * (top - i);
for (int s = 1; s <= stars; s++)
{
Console.Write("*");
}
for (char m = i; m >= 'A'; m--)
{
Console.Write(m);
}
Console.WriteLine();
}
}
}
} When i = 'E', left prints ABCDE, stars = 0, right prints EDCBA — hence the doubled E. As i falls, the letter halves shrink and the even star gap grows, keeping width 10.
Let the user choose the height at runtime.
Compute top = 'A' + rows - 1, then reuse the same three-part row. Prefer int.TryParse in real apps.
using System;
namespace MyApp
{
class Program
{
static void Main(string[] args)
{
Console.Write("Enter the number of rows: ");
int rows = Convert.ToInt32(Console.ReadLine());
char top = (char)('A' + rows - 1);
for (char i = top; i >= 'A'; i--)
{
for (char j = 'A'; j <= i; j++)
{
Console.Write(j);
}
int stars = 2 * (top - i);
for (int s = 1; s <= stars; s++)
{
Console.Write("*");
}
for (char m = i; m >= 'A'; m--)
{
Console.Write(m);
}
Console.WriteLine();
}
}
}
} For rows = 4, top is 'D' and each row has width 8. Clamp rows to 1–26 so top stays within A–Z.
Same shape with a one-call star gap.
new string('*', stars)Keep the letter loops; build the center gap in one call.
using System;
namespace MyApp
{
class Program
{
static void Main(string[] args)
{
char top = 'E';
for (char i = top; i >= 'A'; i--)
{
for (char j = 'A'; j <= i; j++)
{
Console.Write(j);
}
int stars = 2 * (top - i);
Console.Write(new string('*', stars));
for (char m = i; m >= 'A'; m--)
{
Console.Write(m);
}
Console.WriteLine();
}
}
}
} new string('*', stars) creates the whole gap at once. Great once you understand the three-part row; keep the explicit star loop for exams that ask you to show all bounds.
using System; brings in Console. Fix top or compute it from rows.
i goes from top down to 'A' — that is the letter half end.
Print A..i, then 2*(top - i) stars for the center gap.
Print i..A, then Console.WriteLine() to end the fixed-width row.
n rows × 2n characters = O(n²) time, O(1) extra memory.
top = 'E'Trace each outer-loop value of i and check left, stars, and right.
i | Left | Stars | Right | Full row |
|---|---|---|---|---|
'E' | ABCDE | 0 | EDCBA | ABCDEEDCBA |
'D' | ABCD | 2 | DCBA | ABCD**DCBA |
'C' | ABC | 4 | CBA | ABC****CBA |
'B' | AB | 6 | BA | AB******BA |
'A' | A | 8 | A | A********A |
Every row has length 10 = 2×5. Total characters: 5×10 = 50.
Where this multi-part row pattern shows up beyond the homework prompt.
Clearest demo that one row can be several loops in sequence.
Example: omit the right half and watch symmetry break.
Letters shrink while filler grows so width stays constant.
Example: count chars on every row — always 2n.
Ascending then descending loops over the same end letter.
Example: swap right loop direction and break the palindrome.
Swap * for #, spaces, or digits once the structure works.
Example: use new string('#', stars).
Constant-width rows make O(n²) obvious: n × 2n prints.
Example: n = 10 → 200 characters.
Pair with TryParse and 1–26 clamps for A–Z.
Example: reject rows > 26.
Pro Tip: say “left, gap, right” before coding — that story prevents forgetting the mirror half or misplacing WriteLine.
Why this pattern earns a spot after simpler alphabet triangles.
Wrong star count or missing mirror shows up immediately as broken symmetry.
Reuses ascending loops, descending loops, and fill loops together.
Change the fill character or skip the doubled middle with small edits.
Fixed width 2n makes O(n²) easy to explain in interviews.
Pro Tip: learn the three-loop version first; treat new string('*', stars) as a polish shortcut afterward.
Small habits that keep symmetric star-center code clean.
Comment or structure code as left / stars / right so the order stays obvious.
TryParseAvoid crashes when the user types letters instead of a number.
Only call WriteLine() after left, stars, and right all finish.
Stick to 2*(top - i) so the gap stays even and centered.
Trace rows = 3 (ABCCBA / AB**BA / A****A) on paper first.
Pro Tip: if the first row is ABCDEDCBA (one E), you started the right half at i - 1 — fine as a variant, but not this page’s default.
Mistakes that commonly break symmetric star-center patterns.
You get only left letters and stars — no symmetry.
→ Always print i..A after the star gap.
Using top - i (not doubled) misaligns the center and shrinks the width.
→ Keep stars = 2 * (top - i).
Breaking after the left half splits one logical row into three lines.
→ Call WriteLine only after left + stars + right.
Letters or empty input throw FormatException.
→ Prefer int.TryParse and re-prompt on failure.
Printing the left side descending changes the intended pattern.
→ Left is always ascending A..i; right is descending i..A.
Check these inputs before calling the solution done.
Output is AA (left A + right A, zero stars).
Treat as invalid; re-prompt instead of silent empty output.
Expect ...EE... style middle when stars = 0.
Clamp or error — char math leaves A–Z.
Convert.ToInt32 throws — use TryParse.
*Same structure works with #, spaces, or digits.
Try these variations to lock in the pattern.
i - 1 when stars = 0# or spaces instead of *2*(top-i) countTryParse until 1 <= rows <= 262n characters; total work is 2n² — O(n²).2*(top - i) for this centered even gap.i and right starts at i.1 <= rows <= 26 for interactive A–Z programs.Quick Takeaway: left A..i, even star gap, right i..A, then break the line — that is the whole pattern.
| Program | Time | Extra space |
|---|---|---|
| Three loops (Examples 1–2) | O(n²) | O(1) |
new string('*', stars) (Example 3) | O(n²) | O(n) temporary gap string per row |
Each of the n rows prints exactly 2n characters, so total prints are 2n².
The symmetric alphabet / star-center pattern is a multi-part nested-loop exercise with lasting payoff: prefix, even gap, and mirror on a fixed-width row. Master the three-loop version, then optionally shorten the star gap with new string('*', stars).
Practice the three examples above, then continue to Program 16’s centered alphabet pyramid.
Print left, then 2*(top-i) stars, then the mirror — and call WriteLine only after all three parts.
stars = 2 * (top - i) for an even centerWriteLine only after all three parts1 <= rows <= 26 for interactive programsrows > 26 without a clear policyPrint the symmetric star-center pattern the beginner-friendly way.
Left | stars | right
DefinitionEnd letter top→A
Code2*(top-i) stars
CodeAfter all three parts
I/OO(n²) time
AnalysisEach row is: ascending letters from A to the row end, then 2*(top - end) stars, then descending letters back to A. The middle letter appears twice when star count is 0, producing ABCDEEDCBA on the first row. Total width stays constant at 2n characters per row.
Next up: a centered alphabet pyramid with leading spaces and a running letter counter.
12 people found this page helpful