close
Blogtrottr
Yahoo!奇摩知識+ - 分類問答 - 電腦網路 - 已解決
Yahoo!奇摩知識+ - 分類問答 - 電腦網路 - 已解決
關於DEV-C++程式問題(急)(20點)
Jun 18th 2013, 15:29

小弟在資訊作業上遇到了一點困難

還請各位大大們協助解惑

謝謝

以下是問題

在費氏數列.c中第18,19,20行可否刪除?不論可否都要詳述為什麼?
if(n==1||n==2)
return 1; //使費式數列的頭兩個數為1
else

以下為費氏數列.c

#include <stdio.h>
#include<stdlib.h>

long long f(int,long long [ ]); //定義一個函數
int main(void)
{
long long cache[50]={0,1,1}; //定義陣列
int n;
scanf("%d",&n); //第幾個費氏數
printf("f(%d) = %I64d\n",n,f(n,cache)); //呼叫函數並印出其值
system("pause");
return 0;
}

long long f(int n,long long cache[ ])
{
if(cache[n]==0)
if(n==1||n==2)
return 1; //使費式數列的頭兩個數為1
else
cache[n] = f(n-1,cache) + f(n-2,cache); //再次呼叫此函數

return cache[n];
}

This entry passed through the Full-Text RSS service — if this is your content and you're reading it on someone else's site, please read the FAQ at fivefilters.org/content-only/faq.php#publishers. Five Filters recommends: 'You Say What You Like, Because They Like What You Say' - http://www.medialens.org/index.php/alerts/alert-archive/alerts-2013/731-you-say-what-you-like-because-they-like-what-you-say.html

You are receiving this email because you subscribed to this feed at blogtrottr.com.

If you no longer wish to receive these emails, you can unsubscribe from this feed, or manage all your subscriptions
arrow
arrow
    全站熱搜
    創作者介紹
    創作者 candycrushsaga3 的頭像
    candycrushsaga3

    20162016韓劇推薦|討論2016韓劇推薦推薦好看的韓劇推薦與韓劇推薦2016韓劇排行榜前十名 , 好看的韓劇推薦 , 2016韓劇收視率

    candycrushsaga3 發表在 痞客邦 留言(0) 人氣()