参考答案是错的吧?
答案里面的numPeople从未定义
#include <stdio.h> int getAge(int numPeople) { int age; if (numPeople == 1) return 10; else age = getAge(numPeople - 1) + 2; return age; } int main(){ printf("第5个人的年龄是%d岁", getAge(5)); return 0; }
答案里面的numPeople从未定义
#include <stdio.h> int getAge(int numPeople) { int age; if (numPeople == 1) return 10; else age = getAge(numPeople - 1) + 2; return age; } int main(){ printf("第5个人的年龄是%d岁", getAge(5)); return 0; }
2019-06-16
举报