我有一份员工名单(数组),他们将获得如下奖励:
常量工人 = [ {name: "John", prize: 1000, prioritize: 1},
{name: "Andy", prize: 2000, prioritize: 2},
{name: "Bill", prize: 2200, prioritize: 3},
{name: :Carry", prize: 3100, prioritize: 4},
{name: "Asawa", prize: 4000, prioritize: 5}
]; //(数组Worker不固定...)
Let TotalPrize = 7100 // 基金奖金
问题:我想为上面的列表减去 TotalPrize (1-> 2-> 3 ...),以便工人按优先级顺序获得全奖:
约翰:1000(满)
安迪:2000(满)
账单:2200(满)
Carry:1900(上表Carry一定是3100,但是因为TotalPrize = 7100已经提前分了前三个剩下的1900)
浅泽:0(因为前4人的钱都分了)
谁有解决方案,帮我解决问题,2个星期的无奈。好难过
相关分类