请问为什么是n-1呢?我一直错
int nianling(int n)
{
int age;
if(n==1)
{
age = 10;
}
else
{
age = nianling(n-1)+2;
}
return age;
}
int main()
{
int pp= nianling( 5);
printf("第5个人的年龄是%d岁",pp);
return 0;
}
int nianling(int n)
{
int age;
if(n==1)
{
age = 10;
}
else
{
age = nianling(n-1)+2;
}
return age;
}
int main()
{
int pp= nianling( 5);
printf("第5个人的年龄是%d岁",pp);
return 0;
}
2020-02-14
举报