求大神帮忙看一下
#include <stdio.h>
int getPeopleAge(int n)
{
int age; //定义年龄
if(n == 1)
{
return 10; //递归结束条件
}
else
{
age = getPeopleAge(n-1)+2; //递归
printf("第%d个人%d岁\n",n,age); //第几个人,岁数
return age;
}
}
int main()
{
int age = getPeopleAge(5);
printf("第5个人的年龄是%d岁。\n", age);
return 0;
}
为什么在 “age = getPeopleAge(n-1)+2; //递归” 中,不能是“age = getPeopleAge(n)+2;”?