标签:
作业描述:
移除一个数组中第一个负数后的所有负数
object Except { def main(args: Array[String]) { val arr = Array(0,2,-3,1,2,3,-3,-6,-7); var flag = 1 var index = 1; arr.map { e => if(flag > 0) { if (e > 0) { index = index + 1 } if (e < 0) flag = -1 } } var i = -1; arr.filter{e => i = i + 1 e >= 0 || i == index }.foreach(println) // print(index); } }
标签:
原文地址:http://www.cnblogs.com/BigdataSpark/p/5094545.html