I was trying to do the first the problem (problem a) in a single.
Write a program that will allow user to choose to display traingles
and diamonds composed of asterisks ina lopping condition?
a. Display the traingles one below the other, like this:
*
**
***
****
*****
*****
****
***
**
I could do that in the following way.
class puzzles
{
private const int height = 100;
private const int flipPoint = 5;
public static void DrawDiamondTriangle()
{
const int CountChars = 102;
const int FlipPoint = 5;
int Counter = 0;
int CharPerLine = 1;
int tempcounter =0;
bool isDescending = false;
int flipCount = 0;
while (Counter < CountChars)
{
Console.Write("*");
Counter++;
if ((Counter - CharPerLine) == tempcounter)
{
flipCount++;
if (flipCount == FlipPoint)
{
isDescending = !isDescending;
flipCount = 1;
}
Console.WriteLine("");
if (isDescending)
CharPerLine--;
else
CharPerLine++;
tempcounter = Counter;
}
}
}
*