//ArrayList needs=new ArrayList();
//            #region 加载测试数据
//            for (int i = 0; i < 5; i++)
//            {
//                needs.Add(3);
//            }
//            for (int i = 0; i < 7; i++)
//            {
//                needs.Add(1.55);
//            }
//            for (int i = 0; i < 9; i++)
//            {
//                needs.Add(1.66);
//            }
 
//            #endregion

//            //从大到小排序
//            IComparer myComperMethod = new comper();
//            needs.Sort(myComperMethod);

//            string result = string.Empty;
//            //迭代方法
//            for (int i = 0; i < needs.Count; )
//            {
//                double temp =double.Parse(needs[i].ToString());
//                ArrayList tempResult = new ArrayList();
//                tempResult.Add(needs[i]);
//                needs.RemoveAt(i);

//                for (int j = 0; j < needs.Count; )
//                {
//                    if (temp + double.Parse(needs[j].ToString()) > 6)
//                    {
//                        j++;
//                    }
//                    else
//                    {
//                        temp += double.Parse(needs[j].ToString());
//                        tempResult.Add(needs[j]);

//                        needs.RemoveAt(j);
//                    }
//                }

//                //记录结果
//                for (int k= 0; k < tempResult.Count; k++)
//                {
//                    result += tempResult[k].ToString() + ",";
//                }
//                result += "<br>";
//            }
           
//            Response.Clear();
//            Response.Write(result);
//            Response.End();

posted on 2011-03-07 16:08 sanmao 阅读(136) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航:
 

常用链接

留言簿(5)

随笔分类

随笔档案

搜索

  •  

最新评论

阅读排行榜

评论排行榜