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


FroglegRank #1,020 · 1.9K reputationPosted May 12, 2011, 1:01 AM EDT
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]);
}
}
}
Dorababu MekaRank #457 · 5.5K reputationPosted May 12, 2011, 1:05 AM EDT
VulpesRank #55 · 29.2K reputationPosted May 12, 2011, 1:53 AM EDT
Anil KumarRank #942 · 2.2K reputationPosted May 12, 2011, 2:27 AM EDT
why you have use Math.Abs function???
VulpesRank #55 · 29.2K reputationPosted May 12, 2011, 2:49 AM EDT
If you remove the Math.Abs, you'll find that it doesn't work correctly.
FroglegRank #1,020 · 1.9K reputationPosted May 12, 2011, 9:52 AM EDT
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
VulpesRank #55 · 29.2K reputationPosted May 12, 2011, 10:22 AM EDT
FroglegRank #1,020 · 1.9K reputationPosted May 12, 2011, 10:35 AM EDT
Sam HobbsRank #107 · 20.5K reputationPosted May 12, 2011, 12:33 PM EDT
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);
FroglegRank #1,020 · 1.9K reputationPosted May 12, 2011, 12:49 PM EDT
Asterisk you take when you play with stars
VulpesRank #55 · 29.2K reputationPosted May 12, 2011, 1:26 PM EDT
Sam HobbsRank #107 · 20.5K reputationPosted May 12, 2011, 1:46 PM EDT