摘要: 太久没写代码了,今天看视频教程,谈到用非递归方法实现斐波那契数列,居然愣了一下,煞笔了……#includeint fab(int a) { if(a<=2)return 1; int pre = 0; int cur = 1; for(int i=2;i<=a;i++) { int temp = pre; pre = cur ; cur = temp + pre; } return cur;}int main(){ int a; //1 1 2 3 5 8 13 while(scanf("%d",&a)!=EOF){ printf("%d\n& 阅读全文
posted @ 2012-06-06 20:15 AndreMouche 阅读(356) 评论(0) 推荐(0) 编辑