有人可以用一种简单的方法告诉我在C#中实现空心矩形吗?
我已经能够制作一个简单的矩形,但我看到的是空心矩形程序,无论是包含还是数组,或者都是非常复杂的.例如,另一个论坛上的解决方案似乎过于具有挑战性,而CodeReview.SE上的这个答案太难理解了.
这就是我所做的,它显示了一个简单的(填充)矩形.if如果可能,如何使用逻辑输出空心矩形?
class Nested_Loops_Hollow_Rectangles
{
public void RunExercise()
{
// how are now supposed to make this hollow?
// columns are side by side, rows is number of top to bottom
// see tut
Console.WriteLine("Welcome to the HollowRectanglePrinter Program.");
Console.WriteLine("How many columns wide should the rectangle be?"); //i.e. 4
int iColMax, iRowMax;
string userChoiceC = Console.ReadLine();
Int32.TryParse(userChoiceC, out iColMax);
Console.WriteLine("How many rows tall should the rectangle be? "); //i.e. 4
string userChoiceR = …Run Code Online (Sandbox Code Playgroud)