Using System;
public class Test
{
public static void Main()
{
double r, x, y;
Console.WriteLine("r = ");
r = double.Parse(Console.ReadLine());
Console.WriteLine("x = ");
x = double.Parse(Console.ReadLine());
if (x<=0) y = -0.5*x;<br> else if (x<=r) y = -Math.Sqrt(4-x*x)+2;<br> else if (x<=2*r) y = Math.Sqrt(4-(x-2)*(x-2));<br> else y = -x+2*r;
Console.WriteLine("y = " + y);
Console.ReadLine();
}
}
Пример:
r = 2
x = 3
y = 1.73205080756888