Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.IO;
- namespace ConsoleApplication2
- {
- struct SPoint
- {
- public int x,y;
- //public bool flag = false;
- public SPoint (int x, int y)
- {
- this.x = x;
- this.y = y;
- }
- public void Show()
- {
- Console.WriteLine("{0}, {1}", x, y);
- }
- public double Distance()
- {
- return Math.Sqrt(x*x + y*y);
- }
- }
- class Program
- {
- static void Main(string[] args)
- {
- using (StreamReader input = new StreamReader("e:/practice/input.txt", Encoding.GetEncoding(1251)))
- {
- int n = int.Parse(input.ReadLine());
- SPoint [] array = new SPoint[n];
- for (int i = 0; i < n; i++)
- {
- string [] x_y = input.ReadLine().Split(' ');
- array[i].x = int.Parse(x_y[0]);
- array[i].y = int.Parse(x_y[1]);
- }
- using (StreamWriter output = new StreamWriter("e:/practice/output.txt", false))
- {
- double min = array[0].Distance();
- SPoint ans = array[0];
- for (int i = 1; i < n; i++)
- if (array[i].Distance() < min)
- min = array[1].Distance();
- output.WriteLine("Наименее удаленная точка — ({0}, {1})", ans.x, ans.y);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement