111,098
社区成员




using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
var X = new decimal[] { 11.8M, 12, 13.3M, 14, 15.6M, 16, 17, 18.8M, 19, 20.5M };
decimal y0 = X[0];
var Y = Enumerable.Range(1, X.Length - 1).Select(i => { decimal x = (X[i] + y0) / 2; y0 = x; return Math.Round(x, 2); }).ToArray();
Y.ToList().ForEach(x => Console.WriteLine(x));
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
var X = new decimal[] { 11.8M, 12, 13.3M, 14, 15.6M, 16, 17, 18.8M, 19, 20.5M };
decimal y0 = X[0];
var Y = X.Select(y => { decimal x = (y + y0) / 2 ; y0 = x; return Math.Round(x, 2); }).Skip(1).ToArray();
Y.ToList().ForEach(x => Console.WriteLine(x));
}
}
}