Проблема с выводом в консоль крестов (консольная графика c помощью символа #) на c#
Мне необходимо сделать правильный вывод в консоль с параметрами width, columns и rows как указано на рисунке:
Мой код:
public static void Main(string[] args)
{
Console.WriteLine("width:");
int W = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("columns:");
int C = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("rows:");
int R = Convert.ToInt32(Console.ReadLine());
for (int i = 0; i < R; i++)
{
Picture(W);
Console.WriteLine("");
}
}
static void Picture(int width)
{
for (int i = 0; i < width; i++)
{
Console.WriteLine(" #");
if (i == 1)
{
for (int j = 1; j < width; j++)
{
Console.Write('#');
}
}
}
}
Такой вопрос: Как мне правильно вывести рисунок крестов в колонки и строки по заданным параметрам?
Ответы (1 шт):
Автор решения: Владислав Дмитриев
→ Ссылка
Разобрался с функцией, если кому будет нужнo:
static void DrawCross(int width, int columns, int rows)
{
for (int i = 0; i < rows * width; i++)
{
for (int j = 0; j < columns * width; j++)
{
if (((i + width / 2 + 1) % width == 0) || ((j + width / 2 + 1) % width == 0))
Console.Write("#");
else
Console.Write(" ");
if ((j + 1) % width == 0)
Console.Write(" ");
}
if ((i + 1) % width == 0)
Console.WriteLine();
Console.WriteLine();
}
}