c#取值算法 本帖最后由 shan7719515 于 2011-10-20 15:43:40 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 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; } } 如何按条件删除ViewState缓存。 求教高人:如何实现“内部带有箭头”的分割条功能 记事本 关于FTP LIST 命令 C#里面有没有读取行的控件? 求一算法 SQL查询并赋值给textbox 请教各位,winform 的打印功能一般用什么方法? LINQ如何根据月份进行分组? 请问怎么把一个dataSet数据源绑定到一个treeview控件?急啊!!!!! 请教关于如何声明类的选择 在线等!急!!!
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;
}
}