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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Lai Jianlie10 reputationPosted Oct 26, 2014, 5:28 AM EDT
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);
}
}
}
VulpesRank #55 · 29.2K reputationPosted Oct 26, 2014, 8:55 AM EDT