跳转到主要内容
你行网

Main navigation

  • 首页
  • 文章
  • 教程
  • 视频
  • 下载
  • 社区
  • 网站导航
User account menu
  • 登录

面包屑

  1. 首页

用递归的思想解决frogJump问题

由 hzh, 7 四月, 2023
ublic class qingwa { /* 一共有n个台阶,一只青蛙每次只能跳一阶或是两阶,那么一共有多少种跳到顶端的方案?例如n=2,那么一共有两种方案,一次性跳两阶或是每次跳一阶。 */ public static int frogJump(int n){ if (n == 1 || n == 2){ return n; }else { return frogJump(n -2) + frogJump(n - 1); } } public static void main(String[] args) { System.out.println(frogJump(1)); System.out.println(frogJump(2)); System.out.println(frogJump(3)); System.out.println(frogJump(10)); } }

标签

  • java
  • 登录或注册以发表评论

评论

相关文章

实验6 Java的类的定义和使用
Mybatis+JUL+Lombok+Maven的图书管理系统
java求水仙花数

文章标签

CSS
Excel
ubuntu
php
五笔
vim
Linux
HTML
command
drupal 7
composer
centos
Mysql
drupal 8
模块(module)
VPN
drush
JavaSrcipt
apache
drupal 9
英语
Drupal
SEO
nerdtree
network
果树种植
surround
drupal10
主题(theme)
phpmyadmin
ssh
权限
yum
二进制
声音
ssl
selinux
HTML5
用户
password
Dreamweaver
flameshot
颜色
翻译
uploadprogress
DDEV
视图(views)
firewalld
gzip
快捷键
kernel
xdebug
错误
ckeditor
mbstring
C语言
简介
源地址
php扩展
电脑基础
certbot
git
apt
压缩解压
表单
电子秤
httpd
WireGuard
邮件验证
breadcrumb
AI
superfish
diff
重定向
网站备份
摄影
tagclouds
docker
java
csharp
短信验证
adsense
drupal9
电脑技巧
simple_adsense
算法
RSS
youtube
版本号
JavaScript
badblocks
端口
cookie
VUE
网站运营
计算机基础
gimp
form
mod_expires 模块
nginx
zip
http验证
重定向,301
curl
netstat
input
赚钱
ip
dns
RFID
标签优化
drupal11
maven
drupal 11
npm
哈希值
字段
更多
RSS源
本站由阿里云强力驱动,幸运券优惠链接
Copyright © 2019 - 2021 你行网 版权所有  粤ICP备19072650号