下列不是遞歸函數的是( )。
下列不是遞歸函數的是( )。
A.int t(int n)
{ if(n==0) return 0;
else return(n-1);
}
B.int t(int n)
{ if(n==0) return 0;
else return t(n-1);
}
C.int t(int n)
{ if(n==0) return 0;
else return n+t(n-1);
}
D.int t(int n)
{ if(n==0) return 1;
else return n*t(n-1);
}
A.int t(int n)
{ if(n==0) return 0;
else return(n-1);
}
B.int t(int n)
{ if(n==0) return 0;
else return t(n-1);
}
C.int t(int n)
{ if(n==0) return 0;
else return n+t(n-1);
}
D.int t(int n)
{ if(n==0) return 1;
else return n*t(n-1);
}
查看答案解析
【正確答案】
A 【答案解析】
只有A選項的else部分返回值時沒有再次調用函數,所以答案選A。參見教材P175。 本題知識點:函數的嵌套調用和遞歸調用,
讓自考更有氛圍,想加入自考365交流群請添加小編微信zbzikao365
你可能喜歡
關注添加
掃碼加入備考交流群
與更多考生一起交流學習經驗
備戰考試,獲取試題及資料
掃碼下載APP
海量歷年試題、備考資料
免費下載領取
掃碼進入微信小程序
每日練題鞏固、考前模擬實戰
免費體驗自考365海量試題

