Problem:
Sorting Five Numbers

Write a program which reads five numbers and sorts them in descending order.

Input

Input consists of five numbers a, b, c, d and e (-100000 ≤ a, b, c, d,e ≤ 100000). The five numbers are separeted by a space.

Output

Print the ordered numbers in a line. Adjacent numbers should be separated by a space.

Sample Input

3 6 9 7 5

Output for the Sample Input

9 7 6 5 3

Solution in C (judge verdict: Time Limit Exceeded)

#include  <stdio.h>

void QSort(int x[ ], int left, int right);
void Swap(int x[ ], int i, int j);
void ShowData(int x[ ], int n);


void QSort(int x[ ], int left, int right)
{
    int i, j;
    int pivot;

    i = left;                      
    j = right;                     

    pivot = x[(left + right) / 2]; 

    while (1) {                    

        while (x[i] > pivot)       
            i++;                   

        while (pivot > x[j])      
            j--;                   
        if (i >= j)                
            break;

        Swap(x, i, j);             
        i++;                      
        j--;
    }    

    if (left < i - 1)            
        QSort(x, left, i - 1);    
    if (j + 1 <  right)          
        QSort(x, j + 1, right);   
}

 
void Swap(int x[ ], int i, int j)
{
    int temp;

    temp = x[i];
    x[i] = x[j];
    x[j] = temp;
}



void ShowData(int x[ ], int n)
{
    int i;

    for (i = 0; i < n ; i++)
        printf("%d ", x[i]);
    printf("\n");
}

int main()
{     
  int x[5]; 
  int n = 5, t, i;

    while(1){
    t=0;
    for(i=0;i<4;i++){
      scanf("%d", &x[i]);
    }
    if(scanf("%d", &x[4])==EOF) t=1;


    
    QSort(x, 0, n - 1);

    
    ShowData(x, n);
    }
    return 0;
}