首页 > 学院 > 开发设计 > 正文

排序的另一种思路

2019-11-17 03:20:50
字体:
来源:转载
供稿:网友

排序的另一种思路

            Console.WriteLine("start:出自http://www.VEVb.com/ahjesus尊重作者辛苦劳动成果,转载请注明出处,谢谢!");            List<int> sourceArr = new List<int> { 99, 51, 61, 41, 8, 73, -3, 225, 3, 10, 0 };            int maxIndex = sourceArr.Max() * 10 + 1;            object[] replaceArr = new object[maxIndex];            sourceArr.ForEach(it => { replaceArr[it < 0 ? ~it * 10 : it * 10] = it; });            IEnumerable<object> result = replaceArr.Where(it => it != null);            foreach (var it in result) {                Console.WriteLine(it);            }


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表