int getAge(int numpeople)
{
int age;
if(numpeople==1)
return 10;
else
int age = getAge(numpeople-1)+2;
return age;
}
int main()
{
int age = geatAge(5);
printf("第5个人的年龄是%d岁", age);
return 0;
}
int age = geatAge(5);//调用函数错误
正确为:
int age=getAge(5);