摘要: 1.二分法2.Newton迭代法public int sqrt(int x) {//newton int i = 1; while(Math.abs(i*i-x) > 1)//精度控制 { i = (i+x/i)/2; } return i; }通过控制精度得到对... 阅读全文
posted @ 2016-01-19 21:37 codingcat 阅读(365) 评论(0) 推荐(0) 编辑
摘要: 接触spark有快一年了,对于scala语言的态度一直看不懂才查API、看资料。最近有比赛要用,所以开始认真学习scala。看的是《快学scala》这本书,记下自认为有用的语言特性及代码。package examplesobject Example1 { def main(args: Array[... 阅读全文
posted @ 2016-01-19 21:35 codingcat 阅读(149) 评论(0) 推荐(0) 编辑
摘要: 1.含有“is”的行数val lines = sc.textFile("file:///usr/spark/spark-1.0.0-bin-hadoop2/README.md")lines.countval isrdd = lines.filter(line => line.contains("is... 阅读全文
posted @ 2016-01-19 21:29 codingcat 阅读(252) 评论(0) 推荐(0) 编辑