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;
- namespace ConsoleApp36
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.WriteLine("Unesi n:");
- int n = Convert.ToInt32(Console.ReadLine());
- List<string> adrese = new List<string>();
- List<int> x = new List<int>();
- List<int> y = new List<int>();
- Console.WriteLine("Unesi adrese i koordinate:");
- for (int i = 0; i < n * 2; i++)
- {
- if (i % 2 == 0)
- {
- adrese.Add(Console.ReadLine().Trim());
- }
- else
- {
- string str = Console.ReadLine();
- x.Add(Convert.ToInt32(str.Substring(0, str.IndexOf(" "))));
- y.Add(Convert.ToInt32(str.Substring(str.IndexOf(" "))));
- }
- }
- List<string> lista1 = new List<string>();
- for (int j = 0; j < n; j++)
- {
- for (int k = j + 1; k < n; k++)
- {
- lista1.Add(adrese[j] + "-" + adrese[k] + "/" + Convert.ToString(Math.Round(Math.Sqrt(Math.Pow(x[j] - x[k], 2) + Math.Pow(y[j] - y[k], 2)), 2)));
- }
- }
- string pom = "";
- for (int i = 0; i < lista1.Count - 1; i++)
- {
- for (int j = i + 1; j < lista1.Count; j++)
- {
- if (Convert.ToDouble(lista1[i].Substring(lista1[i].IndexOf("/") + 1)) > Convert.ToDouble(lista1[j].Substring(lista1[j].IndexOf("/") + 1)))
- {
- pom = lista1[i];
- lista1[i] = lista1[j];
- lista1[j] = pom;
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement