//递归 //Age(5) 表示第5个人的年龄 //Age(4) 表示第4个人的年龄 //Age(3) 表示第3个人的年龄 //Age(2) 表示第2个人的年龄 //Age(n) 表示第n个人的年龄 #include <stdio.h> int Age(int n) { int tmp; if (n == 1)//第1个人的年龄是已知的为10 { return 10; } else tmp = Age(n-1)+2;//自己调用自己个儿 return tmp; } int main() { printf ("%d\n",Age(5)); return 0; }
【C语言】关于递归
猜你喜欢
转载自blog.csdn.net/weixin_41576955/article/details/79954685
今日推荐
周排行