Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace ConsoleApp2
- {
- class Program
- {
- public class point
- {
- public double x;
- public double y;
- public void read()
- {
- string[] input = Console.ReadLine().Split(' ').ToArray();
- this.x = double.Parse(input[0]);
- this.y = double.Parse(input[1]);
- }
- }
- static double dist(point a, point b)
- {
- double x1 = a.x, x2=b.x, y1=a.y, y2=b.y;
- double dist = (x1-x2)*(x1-x2) +(y1-y2)*(y1-y2);
- return ((int)(Math.Sqrt(dist)*10000))/10000.0;
- }
- static void Main(string[] args)
- {
- int x = int.Parse(Console.ReadLine());
- point p1 = new point();
- point p2 = new point();
- List<point> points = new List<point>();
- while (x!=0)
- {
- p1.read();
- points.Add(p1);
- x--;
- }
- x = points.Count;
- double minDist = double.MaxValue;
- for(int i=0; i<x; i++)
- {
- for(int j=i+1; j<x; j++)
- {
- double d = dist(points[i], points[j]);
- if (d<minDist)
- {
- minDist = d;
- p1 = points[i];
- p2 = points[j];
- }
- }
- }
- Console.WriteLine("{0:f3}\n{1} {2}\n{3} {4}", minDist, p1.x, p1.y, p2.x, p2.y);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement