C#技术百科
问问你的心你有没有信心 做事情要专一坚定,执着


//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  王德田  阅读(173)  评论(0编辑  收藏  举报