HDoj:2160 母猪的故事(C语言)

这道题考察的知识点其实就是斐波那契数列

下面附上已AC的代码:

#include<stdio.h>
int main()
{
    int x[21],i,T,N;
    x[0]=0;
    x[1]=1;
    x[2]=2;
    x[3]=3;
    scanf("%d",&T);
    for(i=4;i<=20;i++)
        x[i]=x[i-1]+x[i-2];
    while(T--)
    {
        scanf("%d",&N);
        printf("%d\n",x[N]);
    }
    return 0;
}


相关文章:

  • 2021-07-11
  • 2022-12-23
  • 2021-07-13
  • 2022-12-23
猜你喜欢
  • 2022-02-06
  • 2022-12-23
  • 2022-12-23
  • 2021-12-31
  • 2022-12-23
  • 2022-12-23
  • 2021-05-21
相关资源
相似解决方案