|
2#

楼主 |
发表于 2014-2-22 16:28:52
|
只看该作者
本帖最后由 faunus 于 2014-2-24 11:32 编辑
答案:- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace ConsoleApplication8
- {
- class Program
- {
- static void Main(string[] args)
- {
- //准备
- int[] a = { 50, 23, 98, 24, 15, 36, 12, 25, 95, 25, 687, 45, 123, 45, 11, 20, 31, 214, 88 };
- int beg = 5;
- int end = 10;
- //工作
- var ints = a
- .Select((s, i) => i < beg ? s | 0x40000000 : (i >= end ? s | 0x40000000 : s))
- .OrderBy(s => s)
- .Select((s, i) => i < beg ? s : s & 0x2FFFFFFF);
- //验证
- foreach (var i in ints) Console.Write(i+",");
- Console.ReadKey();
- //12,25,25,36,95,11,15,20,23,24,31,45,45,50,88,98,123,214,687,
- }
- }
- }
复制代码
|
|