public int num = 100;
public int money = 2000;
public int max = 88;
public int min = 1;
private void DataBing()
{
Random rd = new Random();
List<int> list_ten = new List<int>();
for (int i = 0; i < 10; i++)
{
int count=rd.Next(80, 88);
money -= count;
list_ten.Add(count);
}
List<int> list = new List<int>();
//每个人先把最小金额拿到手
for (var i = 0; i < 90; i++)
{
list.Add(min);
}
//计算还剩下多少钱
money -= ((num-10) * min);
//随机分配,直到钱花完
while (money > 0)
{
//在0-99之间随机
int idx = rd.Next(0, 90);
if (list[idx] < max)
{
list[idx] += 1;
money -= 1;
}
}
for (int i = 0; i < list_ten.Count; i++)
{
list.Insert(i * i, list_ten[i]);
}
string a = "";
int b = 0;
for (int i = 0; i < list.Count; i++)
{
if (i % 10 == 0)
{
a += "<br/>";
}
a += list[i] + ",";
b += list[i];
}
Response.Write(a + "<br/>");
Response.Write(b);
}
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。