3 条题解

  • 2
    @ 2021-01-17 13:44:37

    #include <iostream>
    using namespace std;
    int main()
    {
    int n,c,a,b,i;
    cin>>n;
    a=1;
    b=1;
    i=3;
    cout<<a<<" "<<b;

    while(i<=n)
    {

    c=a+b;
    a=b;
    b=c;
    cout<<" "<<c;
    i=i+1;
    }
    return 0;

    }

  • 0

    #include <iostream>
    using namespace std;
    int main()
    {
    int w=1,ww,a=1,b=1,c;
    cin>>ww;

    if(ww<3)
    if(ww!=1)
    cout<<"1 1";
    else
    cout<<"1";
    else
    {
    cout<<a<<" "<<b<<" ";
    while(w<=ww-2)
    {
    c=a;

    a=b;
    b=c+a;
    cout<<b<<" ";
    w=w+1;

    }
    }
    return 0;

    }

  • -2

    #include <iostream>
    using namespace std;
    int main()
    {
    int n,c,a,b,i;
    cin>>n;
    a=1;
    b=1;
    i=3;
    cout<<a<<" "<<b;

    while(i<=n)
    {

    c=a+b;
    a=b;
    b=c;
    cout<<" "<<c;
    i=i+1;
    }
    return 0;

    }

  • 1

A2-2 循环结构入门:斐波拉契数列

信息

难度
7
分类
(无)
标签
递交数
3619
已通过
744
通过率
21%
被复制
8
上传者