include iostream include cmath using namespace std int main int st 100

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <iostream>
#include <cmath>
using namespace std;
int main(){
int n, j,st[1000],sum[1000], i,min=10000;
cin>>n;
for (j=1;j<=n;j++){
cin>>st[j];
}
for (j=1;j<=n;j++){
for (i=1;i<=n;i++){
sum[j]+=sqrt(pow((st[j] - st[i]),2));
}
cout<<sum[j]<<" ";
}
for (j=1;j<=n;j++){
if (min > sum[j]) {min=sum[j]; i = st[j];}
}
cout<<i;
return 0;
}