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:sort

Posted by azma at 2009-03-16 16:19:13 on Problem 2388
In Reply To:Re:sort Posted by:azma at 2009-03-16 16:00:49
#include <stdio.h>
//#include <conio.h>
int min(int a[],int L,int r)
{
	int m=a[L];
	int i,index=L;
	for (i=L+1;i<r;i++)
	if ( m>a[i]){
		m=a[i];
		index=i;
	}
	return index ;
}
void ssort(int a[],int n){
	int i,index;
	for(i=0;i<n-1;i++)
	{
		index=min(a,i,n);
		int temp=a[i];
		a[i]=a[index];
		a[index]=temp;
	}
}
int main()
{
	int n,i;
	scanf ("%d",&n);
	int a[100000];
	for (i=0;i<n;i++)//;
		scanf ("%d",&a[i]);
	ssort(a,n);
	printf("%d",a[n>>1]);
//getch();
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