I have some code for a asterik tree and I can't get the trunk to line up correctly in the middle of the base of the tree it's all over the place depending on what value I put in ( I'm supposed to use odd numbers)
I got the code off the internet so I didn't write it myself. If someone can even explain what it's doing would be enough for me. Thanks for looking at my post
Here's the code:
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Chapter6Problem14
{
class Program
{
static void Main()
{
int rows;
int a, b, c, d, e;
Console.Write("Input an odd number of rows for the asterik tree: ");
rows = Convert.ToInt32(Console.ReadLine());
Console.WriteLine();
for (a = 1; a <= (rows / 2) + 1; a++)
{
for (b = 1; b <= rows - a; b++)
Console.Write("{0}", ' ');
for (c = 1; c <= (2 * a) - 1; c++)
Console.Write("{0}", "*");
Console.WriteLine();
}
for (e = 1; e <= rows - 2; e++)
Console.Write(" ");
for (d = 1; d <= (rows / 2); d++)
{
Console.Write("{0}", '*');
}
Console.WriteLine();
Console.ReadKey();
}
}
}