找回密碼
 註冊
搜索
熱搜: 活動 交友 discuz
查看: 1626|回覆: 0

[原創] 窩狀函數

[複製鏈接]
發表於 2007-5-18 11:46:12 | 顯示全部樓層 |閲讀模式
#include<iostream>
using namespace std;
double fib(int n)
{
if (n<=2){
          return 1;
           }
else {
      return(fib(n-1)+fib(n-2));
      }           
}        
int main()
{
     int x;
     cout<<"請輸入一整數";
     cin>>x;
     cout<<"fib("<<x<<")="<<fib(x);
     
    system ("PAUSE");
    return 0;
}
您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

Checking the Pageranks

Archiver|手機版|小黑屋|WEO

GMT+8, 2026-7-29 08:36 PM , Processed in 0.019388 second(s), 20 queries .

Powered by Discuz! X5.0 Licensed

© 2001-2026 Discuz! Team.

快速回復 返回頂部 返回列表