2016年7月24日
摘要: public class HanoiTower { public static void main(String[] args)throws Exception { hanoiTower(64,"X","Y","Z"); } public static void hanoiTower(int n, String x, String y... 阅读全文
posted @ 2016-07-24 19:40 kuillldan 阅读(173) 评论(0) 推荐(0) 编辑
摘要: 要使用二分法需要注意: 数组中的元素必须已经按升序排列好 二分法主要思想是将一个数组一分为二,每次查询都能将查询范围在上一次的基础上缩小一半。所以效率非常高。 下面是Java代码实现: 输出结果: 1 1 2 2 2 2 3 3 7 7 8 target in: 8 阅读全文
posted @ 2016-07-24 18:36 kuillldan 阅读(2440) 评论(0) 推荐(0) 编辑