//總金額平均分配給總人數dom
//參數說明:總金額,總人數,最大金額爲平均金額的倍率List
public double[] GetList(double zje,int zrs,int max)
{
double total = zje;//總金額
int count = zrs;//總人數
double avg = total / count;
double[] list = new double[count];
int seed = 1;
while (count > 0)
{
if (count == 1)
{
list[zrs- count] = Math.Round(total,2);
count--;
}
else
{
Random r = new Random(seed);
double lv = (double)r.Next(max*100) / 100;
if (total - avg * lv <= 0)
{
seed++;
continue;
}
list[60 - count] = Math.Round(avg * lv,2,MidpointRounding.AwayFromZero);
total -= Math.Round(avg * lv, 2, MidpointRounding.AwayFromZero);
count--;
}
seed++;
}
return list;
}di