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

为什么错啊!谢谢

Posted by y05yxg at 2006-03-26 16:49:08 on Problem 2623
#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:
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