| ||||||||||
| 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 | |||||||||
Re:sortIn Reply To:Re:sort Posted by:azma at 2009-03-16 16:35:17 #include<iostream>
using namespace std;
int n,i,a[9999];
int BubbleSort(int num[], int numel)
{
int i, j, grade, moves = 0;
for ( i = 0; i < (numel - 1); i++)
{
for(j = 1; j < numel; j++)
{
if (num[j] < num[j-1])
{
grade = num[j];
num[j] = num[j-1];
num[j-1] = grade;
moves++;
}
}
}
return moves;
}
int main(){
cin>>n;
for(i=n;i;)cin>>a[--i];
BubbleSort(a,n);
cout<<a[n>>1];
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator