| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
好心人帮看看哪里出错了啊#include"stdio.h"
#include"math.h"
void sort(int a[],int d)
{ int w,temp,n;
for(w=0;w<d;w++)
for(n=d;n>w+1;n--)
if (a[n]>a[n-1])
{temp=a[n];
a[n]=a[n-1];
a[n-1]=temp;}
}
int main()
{
int x[10001],y[10001];
int i=0,j=0,sum=0,p=0;
scanf("%d",&i);
for(j=1;j<=i;j++)
scanf("%d%d",&x[j],&y[j]);
sort(y,i);
for(j=1;j<=i;j++)
sum+=abs(y[j]-y[(i+1)/2]);
sort(x,i);
for(j=(i+1)/2,p=0;j>0;j--,p++)
sum+=abs(x[j]-(x[(i+1)/2]+p));
for(j=(i+1)/2,p=0;j<=i;j++,p++)
sum+=abs(x[j]-(x[(i+1)/2]-p));
printf("%d\n",sum);
return 0;
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator