亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

為什么要再次定義sum?不懂。

#include <stdio.h>?

?int year(int n)

?{

? ? if(n==0)

? ? {

? ? ?return 0;

? ? ?}

? ? ?else if(n==1)

? ? ? {

? ? ? ? return 10;

? ? ? }

? ? ? else

? ? ?{

? ? ? ? int sum;\\這里定義過。\\

? ? ? ? sum=(year(n-1)+2);

? ? ? ? return sum;

? ? ?}

?}

int main()?

{

? ? int sum=year(5);\\這里為什么要加int,前面不是定義過嗎?\\

printf("第5個人的年齡是%d歲", sum);?

return 0;

}


正在回答

2 回答

謝謝你的回答,現在明白了,下節有講局部與全局變量。

0 回復 有任何疑惑可以回復我~

Indeed you difine the SUMs above twice; howeve, different SUMs remain two specific characters as well as the SUM will be output by its own

0 回復 有任何疑惑可以回復我~
#1

舊城不暖少年心 提問者

謝謝你的回答,現在明白了,下節有講局部與全局變量。
2017-05-08 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

為什么要再次定義sum?不懂。

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號