using System;
using System.Collections.Generic;
using System.Linq;
internal class Program {
private static readonly Func<double, double, List<double>>[] Fs_ = {
(x, y) => new List<double> //1
{
-(x * x + y * y - 9 * 9),
x
},
(x, y) => new List<double> //2
{
-(x * x + y * y - 7 * 7),
x * x + y * y - 3 * 3
},
(x, y) => new List<double> //3
{
x * x + y * y - 5 * 5,
-(x * x + y * y - 10 * 10),
y
},
(x, y) => //4 - костыль
{
var values = new List<double> {
-(x * x + y * y - 15 * 15),
x * x + y * y - 25 * 25
};
if (values.Any(v => Math.Abs(v) < 0.01))
return new List<double> {0};
return values.Any(v => v > 0) ? new List<double> {1} : new List<double> {-1};
},
(x, y) => new List<double> //5
{
-(x * x + y * y - 15 * 15),
-(Math.Abs(x) - y)
},
(x, y) => new List<double> //6
{
-(Math.Abs(x) - y),
-(y - 12)
},
(x, y) => new List<double> //7
{
-(x - 70),
x - y,
y
},
(x, y) => new List<double> //8
{
-Math.Abs(x) - y,
-(-y - 100)
},
(x, y) => new List<double> //9
{
-(x * x + y * y - 10 * 10),
-(-x - y)
},
};
private static void Main() {
do {
Console.Write("x = ");
var x = double.Parse(Console.ReadLine() ?? throw new InvalidOperationException());
Console.Write("y = ");
var y = double.Parse(Console.ReadLine() ?? throw new InvalidOperationException());
for (var i = 0; i < Fs_.Length; i++)
Console.WriteLine($"F({i + 1}) => {ContainsPoint(x, y, Fs_[i])}");
} while (true);
Console.ReadKey();
}
private static string ContainsPoint(double x, double y, Func<double, double, List<double>> f) {
var values = f(x, y);
if (values.Any(v => v < 0))
return "Нет";
return values.Any(v => Math.Abs(v) < 0.01) ? "На границе" : "Да"; // Math.Abs(v) < 0.01 сравнение с 0
}
}