10 solutions
-
0
#include<iostream> #include<queue> #include<stack> #include<cmath> #include<algorithm> #include<cstring> using namespace std; int main() { int a; cin>>a; int b[10010];// 开大一点,不然会报Wrong Answer!! int i=0; int n=a; while(n--) { i++; cin>>b[i]; } sort(b,b+a);//用sort排序快一点,注意用法!!sort(?,?+?); int m=b[a-1]-b[0]; cout<<m; return 0; }
-
-1
#include<bits/stdc++.h> using namespace std;
int main(){ int n,maxn,minn; cin>>n; const int N=n; int a[N]; for(int i=0;i<N;i++){ cin>>a[i]; } maxn=a[0]; minn=a[0]; for(int j=0;j<N;j++){ maxn=max(maxn,a[j]);
} for(int k=0;k<N;k++){ minn=min(minn,a[k]); } cout<<maxn-minn; return 0;
}
- 1
Information
- ID
- 598
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 3
- Tags
- # Submissions
- 123
- Accepted
- 66
- Uploaded By