// Fibonaqii.cpp : Defines the entry point for the console application.
/*

data:2013/10/05

auth:ljz

func:

斐波那契数列的非递归实现

*/

#include "stdafx.h"
#include "iostream"
using namespace std;
int Fibonaqii(int n)
{
int a=1,b=1,c;
if (n == 1 || n ==2)
{
return 1;
}
else
{
for (int i =3;i<=n;i++)
{
c = a+b;
a = b;
b = c;
}
return c;
}
}
int main(int argc, char* argv[])
{
int n;
printf("输入n!\n");
cin>>n;
cout<<Fibonaqii(n)<<endl;
return 0;
}

 

相关文章:

  • 2021-09-20
  • 2022-12-23
  • 2022-12-23
  • 2021-08-26
  • 2021-09-11
  • 2022-01-17
  • 2022-12-23
猜你喜欢
  • 2021-09-25
  • 2022-01-14
  • 2021-07-22
  • 2021-12-07
  • 2021-07-30
  • 2022-12-23
  • 2021-12-25
相关资源
相似解决方案