How to make 5 random numbers with sum of 100

前端 未结 8 1656
旧巷少年郎
旧巷少年郎 2020-12-03 13:17

do you know a way to split an integer into say... 5 groups. Each group total must be at random but the total of them must equal a fixed number.

for example I have \"

8条回答
  •  北荒
    北荒 (楼主)
    2020-12-03 13:17

    I think the trick to this is to keep setting the ceiling for your random # generator to 100 - currentTotal

提交回复
热议问题