Пример #1
0
        public List <double> DistributeDouble(double d)
        {
            List <double> res = new List <double>(Ratios.Count);
            double        sum = Ratios.Sum();

            foreach (var r in Ratios)
            {
                double part = d / sum * r;
                res.Add(part);
            }

            return(res);
        }
Пример #2
0
        public List <int> DistributeInt(int i)
        {
            List <int> res = new List <int>(Ratios.Count);

            double sum = Ratios.Sum();

            int remaining = i;

            foreach (var r in Ratios)
            {
                int part = Math.Min(remaining, (int)Math.Round(i / sum * r));
                res.Add(part);
                remaining -= part;
            }

            return(res);
        }