How to do this?

  • Thread starter Thread starter Amanda
  • Start date Start date
Sorry, Cor, but I must follow my conscience. Feel free to follow your own.

--
HTH,

Kevin Spencer
Microsoft MVP
Chicken Salad Shooter
http://unclechutney.blogspot.com

A man, a plan, a canal, a palindrome that has.. oh, never mind.
 
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;

}

}


}
*
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top