I'm trying to print a rectangle of asterisks with its diagonals.
I have the code for it, but I'm wondering if there's any way to make it more symmetrical?
int height = int.Parse(Console.ReadLine());
int width = int.Parse(Console.ReadLine());
for (int i = 0; i < height; i++) {
for (int j = 0; j < width; j++) {
if (i == 0 || j == 0 || i == height - 1 || j == width - 1 || i == j || i + j == width- 1) {
Console.Write("*");
}
else {
Console.Write(" ");
}
}
Console.WriteLine();
}
With an imput of (12, 16) it comes out:
****************
** **
* * * *
* * * *
* * * *
* * * *
* * * *
* ** *
* ** *
* * * *
* * * *
****************