题目描述:
给定一个长度为n的非负整数序列,请计算序列的最大跨度值(最大跨度值 = 最大值减去最小值)。
输入描述:
一共2行,第一行为序列的个数n(1 <= n <= 1000),第二行为序列的n个不超过1000的非负整数,整数之间以一个空格分隔。
输出描述:
输出一行,表示序列的最大跨度值。
输入例子:
6
3 0 8 7 5 9
输出例子:
9
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
int n,t,max=0,min=1000;
cin>>n;
for(int i=1;i<=n;i++)
{
cin>>t;
if(t>max)
max=t;
if(t<min)
min=t;
}
cout<<max-min;
return 0;
}