上一页 1 ··· 37 38 39 40 41
摘要: 前段时间遇到一道题让用递归和非递归的方法实现斐波那契数列,做了下,顺便记录下来递归方法:#includeusing namespace std;int f(int i){ if(i==1||i==2) return 1; else return f(i-1)+f(i-2);}int main(){ coutusing namespace std;int main(){ int n=10; int result_p,result_n,result; result_p=result=1; while (n>2){ result... 阅读全文
posted @ 2013-11-18 18:14 weilq 阅读(706) 评论(1) 推荐(0) 编辑
上一页 1 ··· 37 38 39 40 41