C# 中的数字模式程序



我想打印这样的东西

54321
5432
543
54
5
4
3
2
1

int n = 5;
Console.WriteLine();
for (int i = n; i >= 0; i--)
{
for (int j = 1; j <= i; j++)
Console.Write(i.ToString());
Console.WriteLine();
}
Console.WriteLine();
Console.ReadLine();

我会用while循环解决这个问题

int i = 5, input = 0;
while (i > 0)
{
input *= 10;
input += i--;
}
while (input > 10)
{
Console.WriteLine(input);
input /= 10;
}
while (input > 0)
{
Console.WriteLine(input--);
}

https://dotnetfiddle.net/1L6j6A