include iostream include cmath using namespace std int main int min 10

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream>
#include <cmath>
using namespace std;
int main(){
int n, j, i,min=10000;
cin>>n;
int st[n],sum[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;
}