Run ID 作者 问题 语言 测评结果 时间 内存 代码长度 提交时间
82116 sh25_chenyj 最大值和最小值的差 C++ 通过 0 MS 248 KB 416 2026-01-10 12:39:08

Tests(1/1):


#include<bits/stdc++.h> using namespace std; int main() { int n; cin>>n; int ls[n]; // cout << fixed << setprecision(10) << ce(a); for(int i = 0; i < n; i++){ cin>>ls[i]; } int max = 0; for(int i = 0; i < n; i++){ if(ls[i] > max){ max = ls[i]; } } int min = max; for(int i = 0; i < n; i++){ if(ls[i] < min){ min = ls[i]; break; } } cout<<max-min; return 0; }


测评信息: