Created
April 18, 2016 16:39
-
-
Save drage0/a3ff0fcc4566b1b356a25fae57fe1049 to your computer and use it in GitHub Desktop.
f
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
program zadatak2; | |
type niz = array[1..1000] of integer; | |
var | |
x, y: niz; | |
i, j, minI, n: integer; | |
minS, s: real; | |
function dist(x0, y0, x1, y1: integer): real; | |
begin | |
dist := sqrt((x0-x1)*(x0-x1)+(y0-y1)*(y0-y1)); | |
end; | |
{ Hvala Tina! } | |
procedure unos (n:integer;var x: niz; c: char); | |
var i:integer; | |
begin | |
for i:=1 to n do begin | |
write(c, '[',i,']= '); | |
readln(x[i]); | |
end; | |
end; | |
begin | |
write('n='); | |
readLn(n); | |
unos(n, x, 'x'); | |
unos(n, y, 'y'); | |
minS := MaxInt; | |
for i := 1 to n do begin | |
s := 0.0; | |
for j := 1 to n do begin | |
if (not(i=j)) then begin | |
s := s + dist(x[i], y[i], x[j], y[j]); | |
end; | |
end; | |
if(minS > s) then begin | |
minS := s; | |
minI := i; | |
end; | |
end; | |
writeLn('========'); | |
writeLn('INDEX: ', minI); | |
writeLn('SUM: ', minS:0:4); | |
readLn(); | |
end. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment