Total time limit: 1000ms memory limit: 65536kB
described
output difference of the maximum number and minimum number of a sequence of integers.
Input
first row M, represents an integer number, an integer number of not greater than 10,000;
second line integer M, separated by spaces, the absolute value of each integer not greater than 10,000.
An output
difference between the maximum and the minimum number M of output.
Sample input
5
2 2 5. 7. 4
Sample Output
5
#include<iostream>
using namespace std;
int main(){
int M;
cin>>M;
int a[M+5];
int min=10010;
int max=-10010;
for(int i=1;i<=M;i++){
cin>>a[i];
if(a[i]>max)
max=a[i];
if(a[i]<min)
min=a[i];
}
cout<<(max-min);
return 0;
}