九度oj 1075
来源:互联网 发布:阿里巴巴商机助理 mac 编辑:程序博客网 时间:2024/06/10 10:03
- 题目描述:
编写一个求斐波那契数列的递归函数,输入n值,使用该递归函数,输出如样例输出的斐波那契数列。
- 输入:
一个整型数n
- 输出:
题目可能有多组不同的测试数据,对于每组输入数据,
按题目的要求输出相应的斐波那契图形。
- 样例输入:
6
- 样例输出:
00 1 10 1 1 2 30 1 1 2 3 5 80 1 1 2 3 5 8 13 210 1 1 2 3 5 8 13 21 34 55
- 来源:
2002年清华大学计算机研究生机试真题(第II套)
#include<iostream>#include<stdio.h>using namespace std;int fib(int x){ if(x==0) { return 0; } if(x==1||x==2) { return 1; } if(x>=3) { return fib(x-1)+fib(x-2); } } int main(){ int n; while(cin>>n) { for(int j=0;j<=2*n-2;j=j+2) { for(int i=0;i<j;i++) { cout<<fib(i)<<" "; } cout<<fib(j)<<endl; } } }
0 0
- 九度oj 1075
- 【九度OJ】:九度OJ 1050
- 【九度OJ】:九度OJ 1053
- 【九度OJ】:九度OJ 1056
- 【九度OJ】:九度OJ 1059
- 【九度OJ】:九度OJ 1206
- 九度OJ:1000
- 【九度OJ】 1006
- 九度 OJ 1499
- 九度OJ-1002
- 九度OJ-1003
- 九度OJ 1004
- 九度OJ 1003
- 九度oj 采药
- 九度OJ 1001
- 九度OJ 1015
- 九度oj 1972
- 九度OJ 1161
- 《项目管理修炼之道》阅读笔记(1)
- ant实现批量打包android应用
- python dir __dict__
- [leetcode] 241.Different Ways to Add Parentheses
- MCS 简单博弈
- 九度oj 1075
- linux(四)
- git 常用命令
- oracle 查看用户所在的表空间
- ZOJ Team Formation 3870【位运算】
- uva725_一道水题(优化到了29ms)
- POJ 2631 -- Roads in the North【树的直径 && 裸题】
- 关于百度地图开发中可能遇到Conversion to Dalvik format failed with error 1
- GooglePlay内购In-app Billing 总结