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.Security.Cryptography.X509Certificates;
- namespace ConsoleApp4
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- List<List<int>> list = new List<List<int>>();
- List<double> dist = new List<double>();
- Console.WriteLine("how many points?");
- int n = Convert.ToInt32(Console.ReadLine());
- for (int i = 1; i <= n; i++)
- {
- Console.Write($"x{i}: ");
- int x = Convert.ToInt32(Console.ReadLine());
- Console.Write($"y{i}: ");
- int y = Convert.ToInt32(Console.ReadLine());
- List<int> crds = new List<int>() {x, y};
- list.Add(crds);
- }
- foreach (List<int> i in list)
- {
- int x= i[0], y = i[1];
- double s = Math.Pow(Math.Pow(x, 2) + Math.Pow(y, 2), 0.5);
- dist.Add(s);
- }
- Console.WriteLine($"n{dist.IndexOf(dist.Min()) + 1}, len == {dist.Min()}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement