計算f91(N)之值是多少

[心得]

1.可以不用遞迴,若N<=100則輸出91,反之輸出N-10

 

#include <stdio.h>

int f91(int N)
{
    if(N>=101)
        return N-10;
    else
        return f91(f91(N+11));
}

int main()
{
    int N;
   
    while(scanf("%d",&N)!=EOF)
    {
        if(N==0) break;
        printf("f91(%d) = %d\n",N,f91(N));
    }
    return 0;
}

arrow
arrow
    全站熱搜

    RingsACM 發表在 痞客邦 留言(0) 人氣()