public static float QuadInterp(float x0, float y0, float x1, float y1, float x2, float y2, float x)
return (((x - x1) * (x - x2)) / ((x0 - x1) * (x0 - x2))) * y0 +
(((x - x0) * (x - x2)) / ((x1 - x0) * (x1 - x2))) * y1 +
(((x - x0) * (x - x1)) / ((x2 - x0) * (x2 - x1))) * y2;
public static void Main(string[] args)
Console.WriteLine("Введите 10 значений x и y");
float[] XList = new float[10];
float[] YList = new float[10];
for (int i = 0; i < 10; i++)
Console.Write("x[" + i + "]="); float x = float.Parse(Console.ReadLine());
Console.Write("y[" + i + "]="); float y = float.Parse(Console.ReadLine());
if (x <= XList[i - 1]) throw new Exception();
XList[i] = x; YList[i] = y;
Console.WriteLine("Ошибка ввода..."); i--;
Console.Write("Введите x = ");
float x = float.Parse(Console.ReadLine());
for (int i = 0; i < XList.Length - 2; i++)
if ((x >= XList[i]) && (x <= XList[i + 2]))
float y = QuadInterp(XList[i], YList[i], XList[i + 1], YList[i + 1],
XList[i + 2], YList[i + 2], x);
Console.WriteLine("интерполированная значения равно " + y);
Console.WriteLine("x вне интервала...");
Console.WriteLine("Ошибка ввода...");