using System;
using System.Collections.Generic;
using System.Linq;
internal class Program {
private static readonly Func>[] Fs_ = {
(x, y) => new List //1
{
-(x * x + y * y - 9 * 9),
x
},
(x, y) => new List //2
{
-(x * x + y * y - 7 * 7),
x * x + y * y - 3 * 3
},
(x, y) => new List //3
{
x * x + y * y - 5 * 5,
-(x * x + y * y - 10 * 10),
y
},
(x, y) => //4 - костыль
{
var values = new List {
-(x * x + y * y - 15 * 15),
x * x + y * y - 25 * 25
};
if (values.Any(v => Math.Abs(v) < 0.01))
return new List {0};
return values.Any(v => v > 0) ? new List {1} : new List {-1};
},
(x, y) => new List //5
{
-(x * x + y * y - 15 * 15),
-(Math.Abs(x) - y)
},
(x, y) => new List //6
{
-(Math.Abs(x) - y),
-(y - 12)
},
(x, y) => new List //7
{
-(x - 70),
x - y,
y
},
(x, y) => new List //8
{
-Math.Abs(x) - y,
-(-y - 100)
},
(x, y) => new List //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> 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
}
}
Скачать вложение Текст (TXT)