这样写为什么不行
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 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;
}
2017-07-15
举报