import java.util.stream.IntStream; public class Main { public static void main(String[] args) { int[] lights = new int[]{50, 70, 20, 70}; int total = IntStream.range(0, lights.length - 1).map(idx -> 100 - lights[idx] - lights[idx + 1]).filter(area -> area > 0).sum(); System.out.println(total); } }
标签:idx,area,int,OD,lights,华为,70,机试,total From: https://www.cnblogs.com/kitor/p/17625675.html