#119: 308


s220 (謝傑任)

學校 : 不指定學校
編號 : 255
來源 : [36.237.77.251]
最後登入時間 :
2026-02-21 11:56:25
t028. 308 函式與陣列 (費氏數列) | From: [118.163.232.198] | 發表日期 : 2026-01-31 11:42

#include<bits/stdc++.h>

using namespace std;

int n;

int compute(int n){

    if(n<2){

        return n;

    }else{

        return compute(n-1)+compute(n-2);

    }

}

int main()

{

cin>>n;

for(int i=n; i>=1; i--){

        cout<<"fib("<<i<<")="<<compute(i)<<endl;

}

return 0;

}

 
ZeroJudge Forum