#include <stdio.h>
in YEAR(int n)
{
if(n==1)
{
int age;
return 10;
}
else
{
age=YEAR(n-1)+2;
}
return age;
}
int main()
{
int age=YEAR(5);
printf("第5个人的年龄是%d岁", age);
return 0;
}
#include <stdio.h> int YEAR(int n) //int YEAR,不是in YEAR { int age; //你定义age变量的时候要放到if语句外面,不然else语句里的age变量识别不出来 if (n == 1) { return 10; } else { age = YEAR(n - 1) + 2; } return age; } int main() { int age = YEAR(5); printf("第5个人的年龄是%d岁", age); return 0; }