為什么要再次定義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個(gè)人的年齡是%d歲", sum);?
return 0;
}
2017-05-08
謝謝你的回答,現(xiàn)在明白了,下節(jié)有講局部與全局變量。
2017-05-08
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