算法之Linq
int[] arr = new int[] { 1, -3, 9, 4, 2, 5, 1, -4, 0 };
var ts = arr.Select(i => new Tuple<int, int>(5 - i, i)).Distinct().
Where(t => arr.Contains(t.Item1)).Select(t => (t.Item1 <= t.Item2) ? t : new Tuple<int, int>(t.Item2, t.Item1)).Distinct();
foreach (var t in ts)
{
Console.WriteLine("{0} {1}", t.Item1, t.Item2);
}
Console.ReadLine();
补充:软件开发 , C# ,