//有五个人坐在一起,问第五个多少岁,他比第四个大两岁,第四个比第三个大两岁,第三个比第二个大两岁,第二个比第一个大两岁,第一个s10岁
//递归
#include "stdio.h"
int age(int num);
int main(){
int num=5;
int ageofive;
ageofive=age(num);
printf("%d\n",ageofive);
return 0;
}
int age(int num){
int p;
int age_of;
p=num;
if (p==1) {
age_of=10;
return age_of;
}
else
p=p-1;
return (2+age(p));
return 0;
}
注意:定义静态变量可以把每个人的年龄打印出来