Maximum Distance Time Limit: 1000 ms Memory limit: 32768 K any questions? Click Here ^_^ Description
The maximum distance of a batch of integers refers to the difference between the maximum number and the minimum number of these integers. the maximum distance of the input batch of integers is obtained.
Input
The input includes two rows. The first line is used to input n, 1 <= n <= 100;
Enter n integers in the second line. Separate integers with spaces. The integers are-10000 ~ In the range of 10000.
Output
Output the maximum distance of these integers.
Sample Input
53 10 -6 20 -10
Sample output
30
# Include
Int main ()
{
Int m, n, a = 0, B = 1000, I;
Scanf ("% d", & m );
While (m --)
{
Scanf ("% d", & n );
If (n>)
A = n;
If (n B = n;
}
I = a-B;
Printf ("% d \ n", I );
Return 0;
}
# Include
Void main ()
{
Int a [1000], I, j, max, min, B [1000];
Scanf ("% d", & I );
For (j = 0; j Max = a [0];
For (j = 1; j {
If (a [j]> = max) max = a [j];
}
For (j = 0; j Min = B [0];
For (j = 1; j {
If (B [I] <= min) I is changed to j
Min = B [j];
}
Printf ("% d \ n", max-min );
}
# Include
Void main ()
{
Int a [1000], I, j, max, min;
Scanf ("% d", & I );
For (j = 0; j Max = a [0];
For (j = 1; j {
If (a [j]> = max) max = a [j];
}
Min = a [0];
For (j = 1; j {
If (a [j] <= min)
Min = a [j];
}
Printf ("% d \ n", max-min );
}