Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2020
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.84 KB | None | 0 0
  1. using System;
  2.  
  3. class Program
  4. {
  5.     static void Main()
  6.     {
  7.         int[] x=new int[10];
  8.         int[] y=new int[10];
  9.        
  10.         for (int i = 0; i < 10; i++)
  11.         {
  12.             x[i] = Console.Read();
  13.             y[i] = Console.Read();
  14.         }
  15.         double najvece_rastojanje = 0.0;
  16.         int tacka1=0;
  17.         int tacka2=0;
  18.         for (int i=0; i<10; i++)
  19.         {
  20.             for (int j=i+1; j<10; j++)
  21.             {
  22.                 double rastojanje = Math.Sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
  23.                 if (rastojanje > najvece_rastojanje)
  24.                 {
  25.                     najvece_rastojanje = rastojanje;
  26.                     tacka1 = i;
  27.                     tacka2 = j;
  28.                 }
  29.                
  30.             }
  31.                
  32.         }
  33.         Console.WriteLine("Koordinate prve tacke: {0} {1}", x[tacka1], y[tacka1]);
  34.         Console.WriteLine("Koordinate druge tacke: {0} {1}", x[tacka2], y[tacka2]);
  35.         Console.WriteLine("Njihovo rastojanje: {0}", najvece_rastojanje);  
  36.                          
  37.         Console.Read();
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement