递归笔试题
来源:互联网 发布:mac上安装ipad应用 编辑:程序博客网 时间:2024/06/06 01:52
笔试题:第1个人10,第2个比第1个人大2岁,依次递推,请用递归方式计算出第8个人多大?
下面是我的实现方法
class Algorithm {private static Algorithm instance;private Algorithm(){}public int computeAge(int n) throws IllegalAccessException {if(n < 1)throw new IllegalAccessException();if(n == 1) {return 10;}return computeAge(n -1) + 2;}public static synchronized Algorithm getInstance() {if(instance == null) {instance = new Algorithm();}return instance;}}public class Main {public static void main(String[] args) throws IllegalAccessException {Algorithm algorithm = Algorithm.getInstance();System.out.println(algorithm.computeAge(100));}}
- 递归笔试题
- 刷刷笔试题~~[递归]
- 一道循环递归笔试题
- 递归排序编程笔试题
- 笔试题:递归逆序栈
- 一道TCL的笔试题---递归
- 10月23腾讯笔试递归题
- 一道TCL的笔试题---递归
- 一个笔试题的递归解法
- 腾讯笔试题--递归编程(2)
- 【笔试题】一种树形结构--递归赋值(。。。)
- 一道TCL的笔试题---递归
- 一个笔试题 双递归调用
- 刷刷笔试题~~[递归类编程]
- 笔试题之交错数组 Java递归求解
- 全排列算法递归实现(笔试题)
- 深圳蓝韵笔试记录--递归程序题
- <有道笔试题>链表加法的递归实现
- Android开发经验之点击图片判断是否在图片范围之内
- POJ:1679 The Unique MST(判断最小生成树是否唯一)
- 论文
- VC打开我的电脑、宽带连接、控制面板...
- Objective_C动态获取实例属性
- 递归笔试题
- 2-sat->poj 2479 Building roads
- ORA-00257 archiver error. 错误的处理方法
- 关于 libxml/tree.h' file not found
- 将LCD屏幕倒过来显示(LCD翻转)
- mysql学习总结
- 修改ssh端口后无法连接ssh了?
- Eclipse 快捷键 【super~
- UVa 10897 - Travelling Distance