#C9296. Sort and Compute Difference
Sort and Compute Difference
Sort and Compute Difference
You are given multiple test cases. For each test case, the input begins with an integer \(N\) representing the number of elements, followed by \(N\) integers. Your task is to sort the given list of numbers in ascending order and then compute the difference between the maximum and minimum values in the list.
Input Format:
The first line contains an integer \(T\) denoting the number of test cases. Each test case consists of two lines. The first line contains an integer \(N\). The second line contains \(N\) space-separated integers.
Output Format:
For each test case, output two lines: The first line should contain the sorted list (space-separated), and the second line should contain the difference between the maximum and minimum values.
Example:
Input:
3
5
3 1 4 1 5
4
-3 -1 -2 -4
3
-1 -3 -2
Output:
1 1 3 4 5
4
-4 -3 -2 -1
3
-3 -2 -1
2
Note: Ensure that your solution reads from standard input (stdin) and writes to standard output (stdout).
inputFormat
The first line of input contains a single integer \(T\) - the number of test cases. Each test case consists of two lines. The first line contains an integer \(N\) (the number of elements in the list). The second line contains \(N\) space-separated integers.
outputFormat
For each test case, output two lines. The first line should display the sorted list of numbers in ascending order (space-separated). The second line should display the difference between the maximum and minimum element in the list.
## sample3
5
3 1 4 1 5
4
-3 -1 -2 -4
3
-1 -3 -2
1 1 3 4 5
4
-4 -3 -2 -1
3
-3 -2 -1
2
</p>