Вычислить расстояние между точками с координатами (x1,y1), (x2,y2) - C#
Формулировка задачи:
Листинг программы
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- /**
- *
- **/
- namespace ConsoleApplication17
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.WriteLine("Введите x1");
- int x1 = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine("Введите x1");
- int x2 = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine("Введите y1");
- int y1 = Convert.ToInt32(Console.ReadLine());
- Console.WriteLine("Введите y2");
- int y2 = Convert.ToInt32(Console.ReadLine());
- int dist = 0;
- dist = Math.Pow((Math.Pow(x2,2)-Math.Pow(x1,2)) + (Math.Pow(y2,2)-Math.Pow(y1,2)));
- }
- }
- }
Листинг программы
- dist = Math.Pow((Math.Pow(x2,2)-Math.Pow(x1,2)) + (Math.Pow(y2,2)-Math.Pow(y1,2)));
Решение задачи: «Вычислить расстояние между точками с координатами (x1,y1), (x2,y2)»
textual
Листинг программы
- dist = (int)Math.Sqrt((Math.Pow(x2, 2) - Math.Pow(x1, 2)) + (Math.Pow(y2, 2) - Math.Pow(y1, 2)));
ИИ поможет Вам:
- решить любую задачу по программированию
- объяснить код
- расставить комментарии в коде
- и т.д