Код:
using System;
namespace WordsCounter
{
class Bishop
{
private int x, y;
public Bishop(int x, int y)
{
this.x = x;
this.y = y;
}
public bool CanIAttackIt(int x, int y)
{
return Math.Abs(x - y) == Math.Abs(this.x - this.y);
}
}
class Program
{
static void Main(string[] args)
{
var x0 = int.Parse(Console.ReadLine()!);
var y0 = int.Parse(Console.ReadLine()!);
var x = int.Parse(Console.ReadLine()!);
var y = int.Parse(Console.ReadLine()!);
Console.WriteLine((new Bishop(x0, y0)).CanIAttackIt(x, y));
}
}
}
Код:
using System;
namespace WordsCounter
{
class Bishop
{
private int x, y;
public Bishop(int x, int y)
{
this.x = x;
this.y = y;
}
public bool CanIAttackIt(int x, int y)
{
return Math.Abs(x - y) == Math.Abs(this.x - this.y);
}
}
class Program
{
static void Main(string[] args)
{
var x0 = int.Parse(Console.ReadLine()!);
var y0 = int.Parse(Console.ReadLine()!);
var x = int.Parse(Console.ReadLine()!);
var y = int.Parse(Console.ReadLine()!);
Console.WriteLine((new Bishop(x0, y0)).CanIAttackIt(x, y));
}
}
}
Pr: set of 1..20;
x: integer;
begin
Pr := [1, 2, 3, 5, 7, 11, 13, 17, 19];
writeln('Вводите целые числа от 1 до 20, выход по 99');
repeat
write('Число ');
readln(x);
if x < 21 then
if x in Pr then writeln('простое')
else writeln('не простое')
until x = 99
end.
Тестовое решение:
Вводите целые числа от 1 до 20, выход по 99
Число 18
не простое
Число 3
простое
Число 15
не простое
Число 23
Число 19
простое
Число 99