7,765
社区成员
发帖
与我相关
我的任务
分享
static void Main(string[] args)
{
//string s = "";
//print(3, s);
//Console.ReadLine();
printNumber(4, "");
}
static void print(int n, string s)
{
while (n > 1)
{
string ss = s;
for (int j = 9; j >= 0; j--)
{
s = ss + j;
s = s.TrimStart('0');
if (s != "")
print(n - 1, s);
}
n--;
}
for (int i = 9; i >= 0; i--)
{
Console.Write(s + i);
Console.WriteLine();
}
}
static void Main(string[] args)
{
printNumber(4, "");
}
static void printNumber(int n, string s)
{
while (n > 1)
{
string pre = s;
for (int i = 0; i <= 9; i++)
{
s = pre + i;
s = s.TrimStart('0');
printNumber(n - 1, s);
}
n--;
}
for (int i = 0; i <= 9; i++)
{
Console.WriteLine((s + i));
}
}