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<iostream.h> #include"stdio.h" void qsort(unsigned int a[],int s,int t) { int i=s,j=t+1; unsigned int x=a[s]; do { do i++;while(a[i]<x); do j--;while(a[j]>x); if(i<j) { unsigned int temp=a[i]; a[i]=a[j];a[j]=temp; } }while(i<j); a[s]=a[j];a[j]=x; if(s<j-1)qsort(a,s,j-1); if(j+1<t)qsort(a,j+1,t); } int main () { unsigned int n,i,*a; double x; cin>>n; a=new unsigned int[n]; for(i=0;i<n;i++) { scanf("%d",&a[i]); } qsort(a,0,n-1); if(n%2) printf("%0.1f",(float)a[n/2]); else printf("%0.1f\n",(float)(a[n/2]+a[n/2-1])/2.0); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator