public class Test { public static void Main() { Console.Write("Введите координату х исходной точки (1-8): "); int x1=Convert.ToInt32(Console.ReadLine()); Console.Write("Введите координату y исходной точки (1-8): "); int y1=Convert.ToInt32(Console.ReadLine()); Console.Write("Введите координату х нужной точки (1-8): "); int x=Convert.ToInt32(Console.ReadLine()); Console.Write("Введите координату y нужной точки (1-8): "); int y=Convert.ToInt32(Console.ReadLine()); bool r=(Math.Abs(x-x1)*Math.Abs(y-y1)==2) && (x>0) && (x1>0) && (x<9) && (x1<9) && (y>0) && (y1>0) && (y<9) && (y1<9); Console.WriteLine(r); } }
public class Test
{
public static void Main()
{
Console.Write("Введите координату х исходной точки (1-8): ");
int x1=Convert.ToInt32(Console.ReadLine());
Console.Write("Введите координату y исходной точки (1-8): ");
int y1=Convert.ToInt32(Console.ReadLine());
Console.Write("Введите координату х нужной точки (1-8): ");
int x=Convert.ToInt32(Console.ReadLine());
Console.Write("Введите координату y нужной точки (1-8): ");
int y=Convert.ToInt32(Console.ReadLine());
bool r=(Math.Abs(x-x1)*Math.Abs(y-y1)==2) &&
(x>0) && (x1>0) && (x<9) && (x1<9) &&
(y>0) && (y1>0) && (y<9) && (y1<9);
Console.WriteLine(r);
}
}
Непосредственно условие:
(Math.Abs(x-x1)*Math.Abs(y-y1)==2) &&
(x>0) && (x1>0) && (x<9) && (x1<9) &&
(y>0) && (y1>0) && (y<9) && (y1<9)