33,028
社区成员
发帖
与我相关
我的任务
分享
class Program
{
static void Main(string[] args)
{
int a = 10;
int b = 0;
int c = 0;
int count=1;
while(a!=0||b!=0)
{
if (b == 0)
{
a--;
b++;
c++;
}
else
{
b--;
c += 2;
}
count++;
Console.WriteLine(a+" "+b+" "+c);
}
Console.WriteLine(count);
Console.ReadLine();
}
}
a[0] = 1;
a[1] = 1; // 只有1格,一种方法
a[2] = 2; // 只有2格,二种方法
for (i = 3; i < n; ++i)
a[i] = a[i-1] + a[i-2] + a[i-3];跳完三十格有a[30]种方法。