import java.util.Arrays; import java.util.Objects; import java.util.stream.Collectors; public class Main { public static void main(String[] args) { Integer[] emp = new Integer[]{2, 10, 3}; Integer[] scholar = new Integer[emp.length]; for (int i = 0; i < emp.length; i++) { for (int j = i; j < emp.length; j++) { if (emp[i] < emp[j]) { scholar[i] = (emp[j] - emp[i]) * (j - i); break; } if (j == emp.length - 1) { scholar[i] = emp[i]; } } } System.out.println(Arrays.stream(scholar).map(Objects::toString).collect(Collectors.joining(" "))); } }
标签:java,scholar,OD,length,util,华为,emp,Integer,机试 From: https://www.cnblogs.com/kitor/p/17627215.html