模拟发红包

不需要考虑权重问题. 纯随机.xxx
# 例如, 小红发了100块红包. 发给30人. 请给出每个人能收到的钱数
# money = 100
# person = 3
#
# import random
# n = random.random()
# m =random.random() * 100 #(0,1) ->(0,100)
# s = int(m * n)
# print(s)

# # --------------*******--------------
# import random
# def hongbao(money,p):
# lst=[]
# d_money=0
# for i in range(1,p):
# t=random.randint(1,(money-d_money)-(p-i))
# lst.append(t)
# d_money=d_money+t
# lst.append(money-d_money)
# return lst
#
# money=100
# p=3
# for i in range(3):
# lst=hongbao(money,p)
# print(lst)
原文地址:https://www.cnblogs.com/liurenli/p/10028672.html