Shandong University of Technology ACM platform answers about C language 1597 maximum distance

Source: Internet
Author: User

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 );






}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.