99關4計概,C語言問題 - 考試
By Kumar
at 2015-07-02T21:26
at 2015-07-02T21:26
Table of Contents
題目如下
int X(int n){
int i,fn,fnm1=1,fnm2=0;
if(n<=1)return n;
else{
for(i=2;i<n;i++){
fn=fnm1+fnm2;
fnm2=fnm1;
fnm1=fn;
}
return fn;
}
}
求X(6) 回傳多少
(A)5 (B)8 (C)11 (D)14
答案是(B)
個人見解,和實際程式下去跑的結果如下
i=2 , fn=1 , fnm1=1 , fnm2=1
i=3 , fn=2 , fnm1=2 , fnm2=1
i=4 , fn=3 , fnm1=3 , fnm2=2
i=5 , fn=5 , fnm1=5 , fnm2=3
看了考選部的答案,發現答案依然沒改
WHY~~~~~~~~~~~~~~~~個人感覺沒解錯啊@@,是因為我用Dev-C去跑才出問題????
--
int X(int n){
int i,fn,fnm1=1,fnm2=0;
if(n<=1)return n;
else{
for(i=2;i<n;i++){
fn=fnm1+fnm2;
fnm2=fnm1;
fnm1=fn;
}
return fn;
}
}
求X(6) 回傳多少
(A)5 (B)8 (C)11 (D)14
答案是(B)
個人見解,和實際程式下去跑的結果如下
i=2 , fn=1 , fnm1=1 , fnm2=1
i=3 , fn=2 , fnm1=2 , fnm2=1
i=4 , fn=3 , fnm1=3 , fnm2=2
i=5 , fn=5 , fnm1=5 , fnm2=3
看了考選部的答案,發現答案依然沒改
WHY~~~~~~~~~~~~~~~~個人感覺沒解錯啊@@,是因為我用Dev-C去跑才出問題????
--
Tags:
考試
All Comments
By Rachel
at 2015-07-07T20:23
at 2015-07-07T20:23
By Daph Bay
at 2015-07-09T22:53
at 2015-07-09T22:53
By Anonymous
at 2015-07-12T04:30
at 2015-07-12T04:30
By Ophelia
at 2015-07-14T21:43
at 2015-07-14T21:43
By Caitlin
at 2015-07-19T14:47
at 2015-07-19T14:47
By Noah
at 2015-07-22T01:28
at 2015-07-22T01:28
By Robert
at 2015-07-26T16:45
at 2015-07-26T16:45
By Robert
at 2015-07-28T10:52
at 2015-07-28T10:52
By Suhail Hany
at 2015-07-31T05:02
at 2015-07-31T05:02
By Queena
at 2015-08-04T09:22
at 2015-08-04T09:22
By Caitlin
at 2015-08-08T13:56
at 2015-08-08T13:56
By Lauren
at 2015-08-11T05:00
at 2015-08-11T05:00
By Dorothy
at 2015-08-12T05:24
at 2015-08-12T05:24
Related Posts
債務不履行 & 無權代理問題
By Lily
at 2015-07-02T21:24
at 2015-07-02T21:24
台北三元師資心得
By Callum
at 2015-07-02T20:59
at 2015-07-02T20:59
高點建國有機生物教材+上榜心得
By Dorothy
at 2015-07-02T20:49
at 2015-07-02T20:49
工程數學-函數微積分問題
By Carolina Franco
at 2015-07-02T20:03
at 2015-07-02T20:03
後中西醫上榜心得+賣書(下)
By Olivia
at 2015-07-02T19:33
at 2015-07-02T19:33