hiho week 72 register

Ended

Participants:370

Verdict:Accepted
Score:100 / 100
Submitted:2015-11-21 15:59:21

Lang:G++

Edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <iostream>
#include <vector>
using namespace std;
void quickSort(int a[], int head, int tail)
{
    if(head >= tail)
        return;
    int guardValue;
    int guard=head;
    int i,j;
    int temp;
    temp = a[(head+tail)/2];
    a[(head+tail)/2] = a[head];
    a[head] = temp;
    guardValue = a[head];
    i = head;
    j = tail;
    while(i<j)
    {
        while(guardValue <= a[j] && i < j)
            j--;
        
        a[guard] = a[j];
        guard = j ;
        while(guardValue >= a[i] && i < j)
            i++;
        a[guard] = a[i];
        guard = i ;
        
    }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX