計算機概論 程式輸出問題 - 考試

By Bennie
at 2014-07-19T12:07
at 2014-07-19T12:07
Table of Contents
下列以 C 程式語言撰寫之程式執行後產生之輸出為何?
#include <stdio.h>
int g=0;
int fibo(int n) {
g++;
if (n == 1 || n == 2)
return 1;
else
return fibo(n-1)+fibo(n-2);
}
int main() {
printf("%d %d", fibo(5), g);
return 0;
}
答案為59
想請問各位,printf("%d %d",fibo(5),g); 把5帶進去運算,但是我就不懂g了,他沒有
任何的宣告,如果帶進去會怎麼處理啊?好像有一點亂,可以幫我解惑嗎?謝謝
--
#include <stdio.h>
int g=0;
int fibo(int n) {
g++;
if (n == 1 || n == 2)
return 1;
else
return fibo(n-1)+fibo(n-2);
}
int main() {
printf("%d %d", fibo(5), g);
return 0;
}
答案為59
想請問各位,printf("%d %d",fibo(5),g); 把5帶進去運算,但是我就不懂g了,他沒有
任何的宣告,如果帶進去會怎麼處理啊?好像有一點亂,可以幫我解惑嗎?謝謝
--
Tags:
考試
All Comments

By Iris
at 2014-07-23T15:30
at 2014-07-23T15:30

By Genevieve
at 2014-07-27T10:53
at 2014-07-27T10:53

By Olivia
at 2014-07-29T12:40
at 2014-07-29T12:40

By Audriana
at 2014-08-03T07:35
at 2014-08-03T07:35

By Faithe
at 2014-08-04T20:55
at 2014-08-04T20:55

By Isabella
at 2014-08-06T13:08
at 2014-08-06T13:08

By Gilbert
at 2014-08-08T08:46
at 2014-08-08T08:46

By John
at 2014-08-10T20:08
at 2014-08-10T20:08

By Selena
at 2014-08-11T02:33
at 2014-08-11T02:33

By Donna
at 2014-08-12T06:00
at 2014-08-12T06:00

By Elma
at 2014-08-13T18:21
at 2014-08-13T18:21

By Aaliyah
at 2014-08-16T12:05
at 2014-08-16T12:05

By Freda
at 2014-08-19T10:39
at 2014-08-19T10:39

By Dinah
at 2014-08-20T03:37
at 2014-08-20T03:37

By Damian
at 2014-08-24T04:59
at 2014-08-24T04:59

By Ivy
at 2014-08-25T20:10
at 2014-08-25T20:10

By Andrew
at 2014-08-27T14:51
at 2014-08-27T14:51

By Belly
at 2014-09-01T12:30
at 2014-09-01T12:30

By Edward Lewis
at 2014-09-02T04:59
at 2014-09-02T04:59

By Eartha
at 2014-09-04T21:38
at 2014-09-04T21:38

By Delia
at 2014-09-07T08:47
at 2014-09-07T08:47

By Zenobia
at 2014-09-09T11:53
at 2014-09-09T11:53

By Carol
at 2014-09-13T03:56
at 2014-09-13T03:56

By Jessica
at 2014-09-15T12:27
at 2014-09-15T12:27

By Bennie
at 2014-09-19T19:04
at 2014-09-19T19:04
Related Posts
關於TQC WORD PPT專業級證照

By Joe
at 2014-07-19T10:59
at 2014-07-19T10:59
調查局-醫學鑑識組

By Callum
at 2014-07-19T03:29
at 2014-07-19T03:29
有人上過紀傑老師的行政學課程嗎?

By Charlie
at 2014-07-19T00:58
at 2014-07-19T00:58
請推薦報考國營化學組的考試用書

By Faithe
at 2014-07-19T00:15
at 2014-07-19T00:15
等待

By Lucy
at 2014-07-19T00:11
at 2014-07-19T00:11