其他分享
首页 > 其他分享> > 中国电子学会考评中心(三级)T4

中国电子学会考评中心(三级)T4

作者:互联网

 

 总的来说,一个斐波那契的变形吧,不多说了。

代码如下

#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,a[35];
  a[1]=1;
  a[2]=2;
  for(int i=3;i<=30;i++)
  {
    a[i]=a[i-1]+a[i-2];
  }
  while(1)
  {
      int k; 
    cin>>k;
    cout<<a[k];
  }
  return 0;
}

结束.jpg

标签:cout,int,T4,namespace,jpg,考评,include,三级
来源: https://www.cnblogs.com/Tbeet/p/13623075.html