标题:Fibonacci 问题
只看楼主
利剑出鞘
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2008-5-18
 问题点数:0 回复次数:3 
Fibonacci 问题
Problem Description
There are another kind of Fibonacci numbers: F(0) = 7, F(1) = 11, F(n) = F(n-1) + F(n-2) (n>=2).

Input
Input consists of a sequence of lines, each containing an integer n. (n < 1,000,000).

Output
Print the word "yes" if 3 divide evenly into F(n).

Print the word "no" if not.

Sample Input
0
1
2
3
4
5

Sample Output
no
no
yes
no
no
no
搜索更多相关主题的帖子: Fibonacci 
2008-10-02 19:56
守鹤
Rank: 4
来 自:山東臨沂
等 级:贵宾
威 望:12
帖 子:337
专家分:0
注 册:2008-6-20
得分:0 
这是一道斐波那契数列的问题

#include  "stdio.h"

void  Fibo(int a);

int main()
{
int  t[5];
printf("请输入整型数据:\n");
for(int i=0;i<5;i++)
   scanf("%d",&t[i]);
printf("数据的输出为:\n");
for(i=0;i<5;i++)
    fibo(t[i]);
return 0;
}


void  Fibo(int a)
{
    int  actom;
    if(a==0)
       actom=7;
    else if(a==1)
       actom=11;
    else
       actom=fibo(a-1)+fibo(a-2);
    if(actom%3==0)
       printf("%d    yes\n",actom);
    else
       printf("%d    no\n",actom);
}

多少个日日夜夜想起你,只希望有缘再次相见
2008-10-02 20:23
leeco
Rank: 4
等 级:贵宾
威 望:10
帖 子:1026
专家分:177
注 册:2007-5-10
得分:0 
#include <stdio.h>
int main()
{
    int n;
    while(scanf("%d",&n)!=EOF){
        if((n%8+1)%4==3)puts("yes");
        else puts("no");
    }   
}
2008-10-02 22:06
利剑出鞘
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2008-5-18
得分:0 
回复 2# 守鹤 的帖子
Compiling...
150.c
d:\msdev98\bin\1\150.c(3) : error C2018: unknown character '0xa3'
d:\msdev98\bin\1\150.c(3) : error C2018: unknown character '0xbb'
d:\msdev98\bin\1\150.c(6) : error C2085: 'main' : not in formal parameter list
d:\msdev98\bin\1\150.c(6) : error C2143: syntax error : missing ';' before '{'
d:\msdev98\bin\1\150.c(9) : error C2143: syntax error : missing ';' before 'type'
d:\msdev98\bin\1\150.c(9) : error C2143: syntax error : missing ';' before 'type'
d:\msdev98\bin\1\150.c(9) : error C2143: syntax error : missing ')' before 'type'
d:\msdev98\bin\1\150.c(9) : error C2143: syntax error : missing ';' before 'type'
d:\msdev98\bin\1\150.c(9) : error C2065: 'i' : undeclared identifier
d:\msdev98\bin\1\150.c(9) : warning C4552: '<' : operator has no effect; expected operator with side-effect
d:\msdev98\bin\1\150.c(9) : error C2059: syntax error : ')'
d:\msdev98\bin\1\150.c(10) : error C2146: syntax error : missing ';' before identifier 'scanf'
d:\msdev98\bin\1\150.c(13) : warning C4013: 'fibo' undefined; assuming extern returning int
d:\msdev98\bin\1\150.c(14) : warning C4098: 'Fibo' : 'void' function returning a value
d:\msdev98\bin\1\150.c(19) : error C2084: function 'void __cdecl Fibo(int )' already has a body
执行 cl.exe 时出错.

150.obj - 1 error(s), 0 warning(s)
2008-10-02 22:52



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-236153-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.189024 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved