6-1
来源:互联网 发布:百万公众网络测试登录 编辑:程序博客网 时间:2024/04/29 14:41
6-1
(1/1 分数)
题目描述
下n级台阶,每步可下1级或2级台阶。那么从n级台阶下到地面,共有多少种不同的下台阶方案?
输入:n
输出:方案数
多行输入,每一行输入一个正整数n,表示n级台阶
输出格式每一行输出n级台阶的方案数
样例输入12样例输出
12代码框
#include <iostream>using namespace std;const int Max=100;int count_step(int temp);int main(){int temp;int i=0;int a[Max];while(cin>>temp){a[i]=temp;i++;}for(int j=0;j<i;j++){cout<<count_step(a[j])<<endl;}return 0;}int count_step(int temp){if(temp==1) return 1;else if(temp==2) return 2;else return count_step(temp-1)+count_step(temp-2);}
0 0
- 6-1
- 1-6
- 6-1
- 6-1
- 6-1
- -6=~6+1; 6=~-6+1
- 2005-1-6
- 经典故事1-6
- 2005-1-6
- 1-->6--->3
- Project Euler 1-6
- 2010-1-6
- Desperate Housewife 1- 6
- 2010-6-1
- 什么是产业链6+1
- C:1-6
- 2011/6/1
- Hibernate基础教程(6-1)
- 肤色检测(Skin-Detection)
- PAT乙级(Basic Level)真题1002
- 单片机按键去抖显示led
- UML之对象图
- 【SSH-商场】——概览
- 6-1
- 5-2 一元多项式的乘法与加法运算 (20分)
- BZOJ1895: Pku3580 supermemo Splay
- 螺旋矩阵II
- 如何启动 instrumentation ?(android )
- 6-2
- 电子表(开关,复位,调时)
- checkbox多项选中及取消选中
- Hello World!(printf练习)我的第一个C程序:-)