WEB开发网
开发学院软件开发C语言 浅谈分组统计 阅读

浅谈分组统计

 2009-06-14 08:33:35 来源:WEB开发网   
核心提示: 最后,这个程序的输出如下所示:==>ForEach<Key--CountAverage--110,4760.49212242635416221,633,2890.4999179910997943981,3450.50044630780457951,542,3770.500567

最后,这个程序的输出如下所示:

==========> ForEach <============
Key ------Count Average----------
 1   10,476 0.492122426354162
 2  1,633,289 0.499917991099794
 3   981,345 0.500446307804579
 5  1,542,377 0.500567888024527
 6   478,158 0.499376479287702
 8   62,325 0.501552373474687
 9  1,463,104 0.500270067230854
 11   802,680 0.500518684820775
 13   367,798 0.499572390413821
 14   492,947 0.500767958524
 16  2,403,053 0.500023199420802
 17   248,208 0.499988049057847
--- ----------- -----------------
 12 10,485,760 0.50018897689056

==========> Iterate <============
Key ------Count Average----------
 1   10,476 0.492122426354162
 2  1,633,289 0.499917991099794
 3   981,345 0.500446307804579
 5  1,542,377 0.500567888024527
 6   478,158 0.499376479287702
 8   62,325 0.501552373474687
 9  1,463,104 0.500270067230854
 11   802,680 0.500518684820775
 13   367,798 0.499572390413821
 14   492,947 0.500767958524
 16  2,403,053 0.500023199420802
 17   248,208 0.499988049057847
--- ----------- -----------------
 12 10,485,760 0.50018897689056

==========> Linq  <============
Key ------Count Average----------
 1   10,476 0.492122426354162
 2  1,633,289 0.499917991099794
 3   981,345 0.500446307804579
 5  1,542,377 0.500567888024527
 6   478,158 0.499376479287702
 8   62,325 0.501552373474687
 9  1,463,104 0.500270067230854
 11   802,680 0.500518684820775
 13   367,798 0.499572390413821
 14   492,947 0.500767958524
 16  2,403,053 0.500023199420802
 17   248,208 0.499988049057847
--- ----------- -----------------
 12 10,485,760 0.50018897689056

这个程序中用到的 Tuple 类如下所示:

class Tuple<T1, T2>
{
 public T1 Item1 { get; private set; }
 public T2 Item2 { get; private set; }
 public Tuple(T1 item1, T2 item2) { Item1 = item1; Item2 = item2; }
}

class Tuple<T1, T2, T3> : Tuple<T1, T2>
{
 public T3 Item3 { get; private set; }
 public Tuple(T1 item1, T2 item2, T3 item3) : base(item1, item2) { Item3 = item3; }
}

其实 .NET Framework 4.0 Base Class Library 中已经有 Tuple 类了。

上一页  1 2 3 4 

Tags:分组 统计

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接