救命救命 請大神指教
#include
int people(num)
?{?
int age;
?if (people==1)?
?? ? age=10;
?else ??
? ? age= people(num-1)+2;
?? ?return age;?
} ? ??
int main()
?{ ? ?
int age5 = people(5);
?printf("第5個(gè)人的年齡是%d歲",age5 );?
?return 0;
?} //錯(cuò)在哪???我要瘋了!?。槭裁????
2018-02-09
你看看吧。
#include <stdio.h> ?//你的錯(cuò)誤:沒加<stdio.h>
int people(int num)//你的錯(cuò)誤:在num前面加int 強(qiáng)調(diào)傳過來的字符類型
?{?
int age;
?if(num==1) ?? ?//你的錯(cuò)誤:不是people ? 是num(看第二行代碼int people(int num))
?{ age=10;}
?else ??
?{ age= people(num-1)+2;
? ? return age;?
?}
} ? ??
int main()
?{ ? ?
int age5 = people(5);
?printf("第5個(gè)人的年齡是%d歲",age5 ); ?
?return 0;
?}
運(yùn)行成功了,,不知道你的結(jié)果對不對,反正你這樣打結(jié)果是9歲