首页 > 试题广场 >

下列程序A与B功能等价,请填空。

[问答题]

下列程序A与B功能等价,请填空。

程序A:
int f(int n) { 
    if (n<=1) 
        return n; 
    else 
        return f(n-1)+f(n-2);
}

程序B:

int f(int n )
{
    int t0=0,t1=1,t=n;
    while (  (4)  )
    {   
        t=  (5)  ; 
        t0=t1;
        t1=t;
        n--;
    }
    return   (6)  ;
}

    int t0=0,t1=1,t=n;
    while (n>1) {
        t=t0+t1;
        t0=t1;
        t1=t;
        n--;
    }
    return t;
}
发表于 2017-12-05 20:25:22 回复(0)