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:Re 为什么会错??偶是新手高人们帮偶看看

Posted by zfacmilan at 2007-08-27 16:06:51 on Problem 2388
In Reply To:Re 为什么会错??偶是新手高人们帮偶看看 Posted by:guanlianjun at 2007-06-07 00:07:54
冒泡太慢了;用快排!
void SWAP(int &a,int &b)
{
	int p;
	p=a;
	a=b;
	b=p;
}
void quicksort(int list[ ], int left, int right)
{
    int  pivot, i, j ;
    if ( left < right ){
       i=left;   
	   j=right+1;
       pivot=list[left]; 
       do{
           do
		   i++;
           while (list[ i ]< pivot);
           do            
		   j--;
           while (list[ j ]> pivot); 
           if  ( i < j )SWAP(list [ i ],list [ j ]);
        }  while ( i < j );
        SWAP( list [ left ], list [ j ]);
        quicksort( list, left, j-1);
        quicksort( list, j+1, right);
    } 
}

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