1045: Quick Sort
Memory Limit:128 MB
Time Limit:0.500 S
Judge Style:Text Compare
Creator:
Submit:256
Solved:58
Description
Quick sort is a gneral-purpose sorting algorithm commonly used. It provide efficient sorting power for random ordered data set. Write a program that sorts an integer array of size less than 10000 in either ascending or descending order. The elements in the integer array range from 0 to 5000.
The input takes the from:
p a1 a2 ... an
where p is a character and ai's are integers to be sorted. The array ai's are sorted in ascending or descending order when on the value of p 'a' or 'd', respectively. The output is the sorted list of integers separated by a single 'space'.
For example, if the input is
a 10 20 0 15
the output is
0 10 15 20
The input takes the from:
p a1 a2 ... an
where p is a character and ai's are integers to be sorted. The array ai's are sorted in ascending or descending order when on the value of p 'a' or 'd', respectively. The output is the sorted list of integers separated by a single 'space'.
For example, if the input is
a 10 20 0 15
the output is
0 10 15 20
Input
a 10 20 0 15
Output
0 10 15 20
Sample Input Copy
d 247 428 52 925 968 504 504 504 502 347 923 379 115 800
Sample Output Copy
968 925 923 800 504 504 504 502 428 379 347 247 115 52