ура
public Point(double[] coordinates)
throw new ArgumentException("Coordinates array must contain exactly 2 elements (X and Y).");
public static double Distance(Point point1, Point point2)
double deltaX = point2.X - point1.X;
double deltaY = point2.Y - point1.Y;
return Math.Sqrt(deltaX * deltaX + deltaY * deltaY);
public static void PrintDistance(Point point1, Point point2)
Console.WriteLine(quot;Coordinates of Point 1: ({point1.X}, {point1.Y})");
Console.WriteLine(quot;Coordinates of Point 2: ({point2.X}, {point2.Y})");
Console.WriteLine(quot;Distance between Point 1 and Point 2: {Distance(point1, point2):F2}");
Point[] points = new Point[3];
points[0] = new Point(new double[] { 0, 0 });
points[1] = new Point(new double[] { 3, 4 });
points[2] = new Point(new double[] { -2, 6 });
for (int i = 0; i < points.Length - 1; i++)
for (int j = i + 1; j < points.Length; j++)
Point.PrintDistance(points[i], points[j]);
protected string professionName;
public string Name { get { return name; } }
public int Nadbavka { get { return nadbavka; } }
public Profession(string name, int nadbavka)
Console.WriteLine("{0} {1}, slalry: {2}", professionName, name, Calculate());
public abstract int Calculate();
public int Dangerous { get { return dangerous; } }
public Fireman(string name, int nadbavka, int dangerous) : base(name, nadbavka)
public override int Calculate()
return (dangerous + Nadbavka) * 100;
public int Category { get { return category; } }
public Engineer(string name, int category, int nadbavka) : base(name, nadbavka)
public override int Calculate()
return (Nadbavka + category) * 100;
public int Degree { get { return degree; } }
public Scientist(string name, int degree, int nadbavka) : base(name, nadbavka)
public override int Calculate()
return (Nadbavka + degree) * 100;
static void Main(string[] args)
Profession[] firemen = new Profession[5]
Profession[] engineers = new Profession[]
new Engineer("Vasiliy", 2, 1),
Profession[] scientists = new Profession[]
new Scientist("Arseniy", 3, 5),
Profession[] professions = new Profession[15];
professions[i+5] = engineers[i];
professions[i+10] = scientists[i];
static void SortBySalary(Profession[] professions)
for (int i = 0; i < professions.Length; i++)
for (int j = 0; j < professions.Length-1; j++)
if(professions[j].Calculate() < professions[j+1].Calculate())
professions[j] = professions[j + 1];
static void Print(Profession[] professions)
for ( int i = 0; i < professions.Length; i++)
public string DietType { get { return dietType; } }
public Animal(string name, string dietType)
public abstract void MakeSound();
Console.WriteLine(quot;Name: {name}");
Console.WriteLine(quot;Diet type: {dietType}");
public Giraffe(string name) : base(name, "Herbivore")
public override void MakeSound()
Console.WriteLine("Giraffe: *silence*");
public Pig(string name) : base(name, "Omnivore")
public override void MakeSound()
Console.WriteLine("Pig: Oink oink!");
public Elephant(string name) : base(name, "Herbivore")
public override void MakeSound()
Console.WriteLine("Elephant: Trumpet!");
public Lion(string name) : base(name, "Carnivore")
public override void MakeSound()
Console.WriteLine("Lion: Roar!");
public Tiger(string name) : base(name, "Carnivore")
public override void MakeSound()
Console.WriteLine("Tiger: Growl!");
public Monkey(string name) : base(name, "Omnivore")
public override void MakeSound()
Console.WriteLine("Monkey: Ooh ooh aah aah!");
Animal[] animals = new Animal[]
new Giraffe("Giraffe1"), new Giraffe("Giraffe2"), new Giraffe("Giraffe3"),
new Pig("Pig1"), new Pig("Pig2"), new Pig("Pig3"),
new Elephant("Elephant1"), new Elephant("Elephant2"), new Elephant("Elephant3"),
new Lion("Lion1"), new Lion("Lion2"), new Lion("Lion3"),
new Tiger("Tiger1"), new Tiger("Tiger2"), new Tiger("Tiger3"),
new Monkey("Monkey1"), new Monkey("Monkey2"), new Monkey("Monkey3")
Console.WriteLine("Herbivores:");
PrintAnimalsByDietType(animals, "Herbivore");
Console.WriteLine("Carnivores:");
PrintAnimalsByDietType(animals, "Carnivore");
Console.WriteLine("Omnivores:");
PrintAnimalsByDietType(animals, "Omnivore");
static void PrintAnimalsByDietType(Animal[] animals, string dietType)
foreach (Animal animal in animals)
if (animal.DietType == dietType)
using System.Collections.Generic;
public double AverageDuration;
public Series(string title, double averageDuration)
AverageDuration = averageDuration;
Description = quot;Для сериала {title} описание не задано";
public void UpdateDescription(string newDescription)
if (newDescription.Length >= 20 && newDescription.Length <= 200)
Console.WriteLine("Описание должно содержать от 20 до 200 символов.");
Console.WriteLine(quot;Название: {Title}");
Console.WriteLine(quot;Средняя длительность серии: {AverageDuration}");
Console.WriteLine(quot;Описание: {Description}");
Console.WriteLine(quot;Просмотрено: {(IsWatched ? "Да" : "Нет")}");
static void Main(string[] args)
List<Series> seriesList = new List<Series>()
new Series("Breaking Bad", 50.0),
new Series("Game of Thrones", 55.0),
new Series("Stranger Things", 45.0),
new Series("The Office", 25.0)
seriesList.Sort((x, y) => x.Title.CompareTo(y.Title));
Console.WriteLine("Список сериалов:");
foreach (Series series in seriesList)
public string Author { get { return author; } }
public int Year { get { return year; } }
private static int _nextISBN = 1;
public Book(string title, string author, int year)
Console.WriteLine(quot;Название: {title}");
Console.WriteLine(quot;ISBN: {ISBN}");
Console.WriteLine(quot;Автор: {author}");
Console.WriteLine(quot;Год издания: {year}");
static void Main(string[] args)
new Book("Война и мир", "Лев Толстой", 1869),
new Book("Преступление и наказание", "Фёдор Достоевский", 1866),
new Book("1984", "Джордж Оруэлл", 1949),
new Book("Мастер и Маргарита", "Михаил Булгаков", 1966),
new Book("Улисс", "Джеймс Джойс", 1922),
new Book("Маленький принц", "Антуан де Сент-Экзюпери", 1943),
new Book("Гарри Поттер и философский камень", "Дж. К. Роулинг", 1997),
new Book("Гарри Поттер и Тайная комната", "Дж. К. Роулинг", 1998),
new Book("Гарри Поттер и узник Азкабана", "Дж. К. Роулинг", 1999),
new Book("Гарри Поттер и Кубок огня", "Дж. К. Роулинг", 2000)
Console.WriteLine("Информация о всех книгах:");
Console.WriteLine("Введите имя автора для поиска книг:");
string authorToSearch = Console.ReadLine();
Console.WriteLine(quot;Книги автора {authorToSearch}:");
if (book.Author == authorToSearch)
Console.WriteLine("Введите век для поиска книг:");
int centuryToSearch = int.Parse(Console.ReadLine());
Console.WriteLine(quot;Книги, написанные в {centuryToSearch} веке:");
int century = (book.Year - 1) / 100 + 1;