#69. 数组最大最小值之差
数组最大最小值之差
Array Range
Background
Dawei is teaching the basics of arrays. To help students better understand array properties, he posed a simple problem, asking everyone to calculate the difference between the maximum and minimum values in an array.
Problem Description
Given an array length 1 or more of ints, return the difference between the largest and smallest values in the array. Note: the built-in Math.min(v1, v2) and Math.max(v1, v2) methods return the smaller or larger of two values.
Input Format
Input is given from standard input in the following format.
A single line containing multiple integers, representing the elements of the array. Elements are separated by spaces.
Output Format
Output is printed to standard output in the following format.
A single integer, representing the difference between the maximum and minimum values in the array.
Sample
10 3 5 6
7
7 2 10 9
8
2 10 7 2
8
Sample Explanation
For the first sample, the array is . The maximum value is , and the minimum value is . Their difference is .
Constraints
Time limit: second, Memory limit: KiB for each test case.