Hi.
i want below maintain output with the help of Array. what is the program for that?? i have use for loop but i am not getting such output please help me
*
***
*****
*******
*****
***
*
Loading

Sam HobbsPosted May 12, 2011, 5:46 PM
VulpesPosted May 12, 2011, 5:26 PM
FroglegPosted May 12, 2011, 4:49 PM
Asterisk you take when you play with stars
Sam HobbsPosted May 12, 2011, 4:33 PM
This is not the simplest, but I think it is an alternative that satisfies the requirements. I assume that a char is initialized to a space character.
Stars[3] = '*';
for (int i = 0; i < 3; ++i)
{
Console.WriteLine(Stars);
Stars[2 - i] = '*';
Stars[4 + i] = '*';
}
for (int i = 2; i >= 0; --i)
{
Console.WriteLine(Stars);
Stars[2 - i] = ' ';
Stars[4 + i] = ' ';
}
Console.WriteLine(Stars);
FroglegPosted May 12, 2011, 2:35 PM
VulpesPosted May 12, 2011, 2:22 PM
FroglegPosted May 12, 2011, 1:52 PM
static string[] ast = new string[4] { " *", " ***", " *****", "*******" };
as it is Ok in the ide and I just pasted it fron there
Anyway Anil has two ways of doing it now
VulpesPosted May 12, 2011, 6:49 AM
If you remove the Math.Abs, you'll find that it doesn't work correctly.
Anil KumarPosted May 12, 2011, 6:27 AM
why you have use Math.Abs function???
VulpesPosted May 12, 2011, 5:53 AM
Dorababu MekaPosted May 12, 2011, 5:05 AM
FroglegPosted May 12, 2011, 5:01 AM
class Program
{
static string[] ast = new string[4] { " *", " ***", " *****", "*******" };
static void Main(string[] args)
{
for (int i = 0; i < 4; i++)
{
Console.WriteLine(ast[i]);
}
for (int ii = 2; ii >= 0; ii--)
{
Console.WriteLine(ast[ii]);
}
}
}