华为OD机试-公司分奖金

发布时间 2023-08-13 20:33:05作者: 手握钢叉的猹

 

 

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(" ")));
    }
}