15-07-03 for () statement-Print Triangle
1.
Console.Write ("Please enter a few lines to print:");
int a = Convert.ToInt32 (Console.ReadLine ());
for (int i = 1; i <= A; i++)
{
for (int j = 1; J <= I; j + +)
{
Console.Write ("☆");
}
Console.WriteLine ();
}
2.
Console.Write ("Please enter a few lines to print:");
int a = Convert.ToInt32 (Console.ReadLine ());
for (int i = 1; i <= A; i++)
{
for (int j = a-i; J >= 0; j--)
{
Console.Write ("☆");
}
Console.WriteLine ();
}
3.
Console.Write ("Please enter a few lines to print:");
int a = Convert.ToInt32 (Console.ReadLine ());
for (int i = 0; i < A; i++)
{
for (int j = 1; J <= A-(i + 1); J + +)
{
Console.Write ("");
}
for (int k = 1; k <= i + 1; k++)
{
Console.Write ("☆");
}
Console.WriteLine ();
}
4.
Console.Write ("Please enter a few lines to print:");
int a = Convert.ToInt32 (Console.ReadLine ());
for (int i = 1; i <= A; i++)
{
for (int j = 0; J <= I-2; j + +)
{
Console.Write ("");
}
for (int k = 0; k <= a-i; k++)
{
Console.Write ("☆");
}
Console.WriteLine ();
}
4.
Console.Write ("Please enter a few lines to print:");
int a = Convert.ToInt32 (Console.ReadLine ());
for (int i = 1; i <= A; i++)
{
for (int k = 1; k <= a-i; k++)
{
Console.Write ("");
}
for (int x = 1; <= i*2-1; x + +)
{
Console.Write ("☆");
}
Console.WriteLine ();
}
for (int j = 1; j < A; J + +)
{
for (int k2 = 1; K2 <= J; k2++)
{
Console.Write ("");
}
for (int x2 = 1; x2 <= (A-j) *2-1; x2++)
{
Console.Write ("★");
}
Console.WriteLine ();
}
for () statement-Print Triangle