Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:好心人帮看看哪里出错了啊

Posted by catchdream at 2015-04-09 10:38:34 on Problem 1723 and last updated at 2015-04-09 10:39:00
In Reply To:好心人帮看看哪里出错了啊 Posted by:20132430217 at 2015-04-09 10:33:46
> #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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator