這個(gè)輸出為什么是8呀
#include <stdio.h>?
int getAge(numPeople)
{
? ? int age;
? ? if (numPeople==1)
? ? {
? ? ? ?age=10;
? ? }
? ? else?
? ? {
? ? ? ? age= getAge(numPeople-1)+2;
? ? ? ? return age;
? ? }? ?
}
int main()?
{
? ? int fifithAge=getAge(5);
printf("第5個(gè)人的年齡是%d歲", fifithAge);?
return 0;
}
2019-03-22
終止語句要用return語句返回哦!
2019-03-14
if語句內(nèi)少了一個(gè)返回值。