int getage(n)
{
int num;
if(num == 1)
{
return 10;
}
else
{
num =getage(n-1)+2;
}
return num;
}
int main()
{
int fifthage =getage(5);
printf("第5个人的年龄是%d岁", fifthage);
return 0;
}
if(num == 1)这句写错了,你这个num都没定义值。你传进来的n都没用上。应该是if(n == 1)