15 条题解
-
3limingjie LV 7 @ 2022-1-15 15:11:05
#include <stdio.h> #include <iostream> using namespace std; int main() { int n,a,b=-1,c=1001; cin>>n; for(int i=1;i<=n;i++) { cin>>a; if(b<a) { b=a; } if(c>a) { c=a; } } cout<<b-c; }
-
12023-3-29 19:36:15@
/**************************************************************/ #include using namespace std; long long n,x,maxn=-1000,minn=1000; int main(){ cin>>n; for(int i=1;i<=n;i++){ cin>>x; maxn=max(maxn,x); minn=min(minn,x); } cout<<maxn-minn; return 0; }
-
02024-3-18 21:19:02@
//#include <bits/stdc++.h> #include <iostream> #include <stdio.h> #include <math.h> #include <iomanip> using namespace std; const int N = 1e5 + 10; const int INF = 0x3f3f3f3f; int n , a , x , d , cha; int main() { cin >> n; for( int i = 1 ; i <= n ; i++ ) { cin >> a; if( i == 1 ) { d = a; x = a; continue; } if( a < x ) { x = a; } if( a > d ) { d = a; } } cha = d - x; cout << cha; return 0; }
-
02023-12-5 21:56:22@
用的数组+for做的
#include<bits/stdc++.h> using namespace std; int main(){ int n=0,i=1; cin>>n; int a[n+1]; for(int i=1;i<=n;i++){ cin>>a[i]; } int max=a[1],min=a[1]; for(i=1;i<=n;i++){ if(a[i]>max){ max=a[i]; } if(a[i]<min){ min=a[i]; } } cout<<max-min; return 0; }
-
02023-7-12 22:32:34@
#include<iostream> using namespace std; long long n,x,maxn=-1000,minn=1000; int main(){ cin>>n; for(int i=1;i<=n;i++){ cin>>x; maxn=max(maxn,x); minn=min(minn,x); } cout<<maxn-minn; return 0; }
-
02023-4-10 20:52:56@
本来想用冷门词unsigned解这道题的,
结果它丝毫不争气,无奈用回int 终于知道unsigned为什么冷门了。。 各位大佬如果知道用它怎么解,请告诉我吧!🎉️AC代码:
#include<stdio.h> #include<iostream> #include<math.h> using namespace std; int a; int n,maxx=0,minx=100000000; int main() { cin>>n; for(int i=1;i<=n;i+=1) { cin>>a; if(a<0) { continue; } maxx=max(maxx,a); minx=min(minx,a); } cout<<maxx-minx; }
-
02023-3-31 20:46:31@
#include<bits/stdc++.h> using namespace std; int main() { int n,x,m=-1000,m1=1000; cin>>n; for(int i=1; i<=n; i++) { cin>>x; m=max(m,x); m1=min(m1,x); } cout<<m-m1; return 0; }
-
02023-3-29 19:36:18@
#include <stdio.h> #include <iostream> using namespace std; int n,a,maxx=-1000,minn=1000; int main(){ cin >> n; for( int i=1; i<=n ; i++){ cin >> a; maxx = max(a,maxx); minn= min(a, minn); } cout << maxx-minn;
- }
-
02022-12-20 22:08:44@
水。。。 AC代码:
#include<iostream> using namespace std; long long n,x,maxn=-1000,minn=1000; int main(){ cin>>n; for(int i=1;i<=n;i++){ cin>>x; maxn=max(maxn,x); minn=min(minn,x); } cout<<maxn-minn; return 0; }
点个赞吧!
-
02022-1-15 10:28:43@
#include <stdio.h> #include <iostream> using namespace std; int main() { int n,a,b=-1,c=1001; cin>>n; for(int i=1;i<=n;i++) { cin>>a; if(b<a) { b=a; } if(c>a) { c=a; } } cout<<b-c; }
-
02022-1-8 15:23:25@
#include<iostream> using namespace std; int main() { int n,a[1001]; int min=9999,max=0; int i; cin>>n; for(i=1; i<=n; i++) { cin>>a[i]; if(a[i]>max) max=a[i]; if(a[i]<min) min=a[i]; } cout<<max-min<<endl; return 0; }
-
-12023-3-9 22:40:24@
#include <stdio.h> #include <iostream> using namespace std; int main() { int n,a,b=-1,c=1001; cin>>n; for(int i=1;i<=n;i++) { cin>>a; if(b<a) { b=a; } if(c>a) { c=a; } } cout<<b-c; }
-
-12022-12-24 20:12:39@
水题 #include《~~~~iostream》 using namespace std; int n,x,_max=-10000,_min=10000; int main(){ cin>>n; for(int i=1;i<=n;i++){ cin>>x; _max=max(_max,x); _min=min(_min,x); } cout<<_max-_min; } 求赞
-
-12022-10-25 13:23:10@
#include <iostream> #include <stack> #include <cmath> #include <vector> #include <string.h> #include <queue> #include <stdio.h> #include <iomanip> #include <cstdio> #include <algorithm> #define int long long using namespace std; const int N = 1e5 + 10; const int INF = 0x3f3f3f3f; signed main() { int n; cin >> n; int maxn = -INF, minn = INF; for(int i = 1; i <= n; i++) { int x; cin >> x; maxn = max(maxn, x); minn = min(minn, x); } cout << maxn - minn << endl; return 0; }
嗯……
-
-12022-10-15 20:19:34@
#include<iostream>
using namespace std;
int main() { int n;
int a; int max =- 1; int i; int min = 1001; cin >> n; for (i = 1; i <= n; i ++) { cin >> a; if(a > max) { max = a; } if(a < min) { min = a; } } cout << max - min; return 0;
}
- 1
信息
- ID
- 978
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 3
- 标签
- 递交数
- 631
- 已通过
- 325
- 上传者