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.Threading.Tasks;
- using System.IO;
- namespace ConsoleApp2
- {
- struct SPoint
- {
- public int x, y;
- public SPoint(int x, int y)
- {
- this.x = x;
- this.y = y;
- }
- public void Show()
- {
- Console.WriteLine("({0}, {1})", x, y);
- }
- }
- class Program
- {
- static public SPoint[] Input()
- {
- using (StreamReader fileIn = new StreamReader(@"C:/Users/belousaa/Documents/in1.txt", Encoding.GetEncoding(1251)))
- {
- int n = int.Parse(fileIn.ReadLine());
- SPoint[] ar = new SPoint[n]; //описание массива структур
- for (int i = 0; i < n; i++)
- {
- string[] text = fileIn.ReadLine().Split(' ');
- ar[i] = new SPoint(int.Parse(text[0]), int.Parse(text[1])); //вызов конструктора структуры
- }
- return ar; //в качестве результата метод возвращает ссылку на массив структур
- }
- }
- static public double sras(SPoint[] ar, int i, int j)
- {
- return Math.Sqrt((ar[i].x - ar[j].x) * (ar[i].x - ar[j].x) + (ar[i].y - ar[j].y) * (ar[i].y - ar[j].y));
- }
- static void brast(SPoint[] ar)
- {
- double mal = 0;
- for (int i = 0; i < ar.Length - 1; i++)
- {
- for (int j = i + 1; j < ar.Length; j++)
- {
- if (sras(ar, i, j) > mal)
- {
- mal = sras(ar, i, j);
- }
- }
- }
- for (int i = 0; i < ar.Length - 1; i++)
- {
- for (int j = i + 1; j < ar.Length; j++)
- {
- if (sras(ar, i, j) == mal)
- {
- ar[i].Show();
- ar[j].Show();
- Console.WriteLine("\n");
- }
- }
- }
- }
- static void Main(string[] args)
- {
- SPoint[] ar = Input();
- brast(ar);
- }
- }
- }
- /*
- 5
- -2 0
- -3 0
- 11 -11
- -11 11
- -400 0
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement