华为OD机试-公司分奖金
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(" "))); } }