1
2 1 2
3 2 1 2 3
4 3 2 1 2 3 4
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Oct 26, 2014, 12:55 PM
Lai JianliePosted Oct 26, 2014, 9:28 AM
class Program
{
static void Main(string[] args)
{
//How many levels of number you want to print on the console
int level = 4;
PrintNumbers(level);
Console.ReadLine();
}
static void PrintNumbers(int level)
{
for (int i = 1; i <= level; i++)
{
printEmpty(level - i);
printNumbersRow(i);
Console.WriteLine();
}
}
static void printEmpty(int numOfEmpty)
{
for (int i = 0; i < numOfEmpty; i++)
{
Console.Write(" ");
}
}
static void printNumbersRow(int number)
{
for (int i = number; i > 0; i--)
{
Console.Write(i);
}
for (int j = 2; j <= number; j++)
{
Console.Write(j);
}
}
}