[Login|Register]
New post

Show post

Search forum

Read post
求问哪儿错了 [ Topic ] 2012-11-22 20:43:28 dengjunjun
# include <stdio.h>
int Fibonacci(int n);
int main()
{
    int a;
    while(scanf("%d",&a)!=EOF)
        printf ("The Fibonacci number for %d is %d\n\n",a,Fibonacci(a));
    return 0;
}
int Fibonacci(int a)
{
    int i,s[41];
    s[0]=0;
    s[1]=0;
    s[2]=1;
    s[3]=1;
    for(i=4;i<=41;++i)
        s[i]=s[i-1]+s[i-2];
    return s[a]+s[a-1];
}
Reply
Title
Message
(64K)
University of Science and Technology of China
Online Judge for ACM/ICPC
Processed in 1.7ms with 2 query(s).