Run ID | 作者 | 问题 | 语言 | 测评结果 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
128 | xishuai15 | 整数序列的元素最大跨度值 | C++ | 通过 | 0 MS | 248 KB | 378 | 2022-05-14 19:11:21 |
#include<bits/stdc++.h> using namespace std; int main(){ int n, x, y; while(cin>>n){ int a[n]; for(int i=0;i<n;i++){ cin>>a[i]; } if(n==1){ cout<<a[0]; return 0; } x=a[0]; y=a[0]; for(int j=0;j<n;j++){ if(a[j]>x){ x=a[j]; } if(a[j]<y){ y=a[j]; } } cout<<x-y<<endl; } return 0; }