摘要: 对 set 的遍历 1.迭代遍历: Set set = new HashSet(); Iterator it = set.iterator(); while (it.hasNext()) { String str = it.next(); System.out.println(str); } 2.for循环遍历: for (String s... 阅读全文
posted @ 2017-04-08 21:11 Yaaaaa 阅读(209285) 评论(0) 推荐(3)
摘要: Math.random() 生成 大于等于0.0 且小于 1.0 的double 型随机数 ( 0.0 <= Math.random() < 1.0 ) 可以使用它便携简单了表达式,生成任意范围的随机数。 例如: (int)(Math.random() * 10) 返回 0 ~ 9 之间的一个随机整 阅读全文
posted @ 2017-04-08 16:46 Yaaaaa 阅读(1610) 评论(0) 推荐(0)
摘要: 单位是毫秒。 long start = System.currentTimeMillis(); //获取当前时间 long end = System.currentTimeMillis(); //System.nanoTime() 阅读全文
posted @ 2017-04-08 14:58 Yaaaaa 阅读(2304) 评论(0) 推荐(0)
摘要: 题目: 以二维数组形式表示坐标岛屿,求边长。 例子: 思路: 一开始想用最笨的办法,就是两次for循环遍历所有元素,如果为1(1为岛屿),就分别判断 上、下、左、右 是否为岛屿,若不是则 边数+1 。 第二次换了想法, 每一条横向 如果有岛屿,只要连续,那么左右两边和始终为2,如果不连续,则左右两边 阅读全文
posted @ 2017-04-08 10:53 Yaaaaa 阅读(184) 评论(0) 推荐(0)