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:47:42 on Problem 2388 and last updated at 2009-03-16 16:48:33
In 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:
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