本帖最后由 shan7719515 于 2011-10-20 15:43:40 编辑

解决方案 »

  1.   


    class ABC
        {
            //次数最多的那个应该就是稳定值
            Dictionary<double, int> _weights = new Dictionary<double, int>();        public void ReceiveData( double weight ) {
                int count;
                if (_weights.TryGetValue(weight, out count)) {
                    _weights[weight] = count + 1;
                } else
                    _weights[weight] = 1;
            }        public double GetWeight()
            {
                double result=0.0;
                int c=0;
                foreach( var item in _weights)
                {   
                    if(c<item.Value)
                    {
                        c=item.Value;
                        result = item.Key;
                    }
                }
                return result;
            }
        }