Advertisement
PetarAsenov

tw

Jan 17th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.25 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace DistanceBetweenPoint
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             var FirstLine = Console.ReadLine().Split().Select(int.Parse).ToArray();
  14.  
  15.             var firstPoint = new Point()
  16.             {
  17.                 x = FirstLine[0],
  18.                 y = FirstLine[1]
  19.             };
  20.  
  21.             var secoundLine = Console.ReadLine().Split().Select(int.Parse).ToArray();
  22.  
  23.             var secoundPoint = new Point()
  24.             {
  25.                 x = secoundLine[0],
  26.                 y = secoundLine[1]
  27.             };
  28.  
  29.             var result = Distance(firstPoint, secoundPoint);
  30.             Console.WriteLine($"{result:f3}");
  31.         }
  32.         public static double Distance(Point firstPoint, Point secoundPoint)
  33.         {
  34.             var squareX = Math.Pow(firstPoint.x  - secoundPoint.x ,2);
  35.             var squareY = Math.Pow(firstPoint.y - secoundPoint.y, 2);
  36.  
  37.             var result = Math.Sqrt(squareX + squareY);
  38.             return result;
  39.         }
  40.        class Point
  41.        {
  42.         public int x { get; set; }
  43.  
  44.         public int y { get; set; }
  45.        }
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement