[Login|Register]
New post

Show post

Search forum

Read post
Re:what's wrong with my answer,who can tell me [ Topic ] 2012-11-22 20:26:44 dengjunjun
# include <stdio.h>
int main()
{
    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];
    int a,b;
    while(scanf("%d",&a)!=EOF)
        printf ("The Fibonacci number for %d is %d\n",a,(s[a]+s[a-1]));    
    return 0;
}
Reply
Title
Message
(64K)
University of Science and Technology of China
Online Judge for ACM/ICPC
Processed in 1.8ms with 2 query(s).