Run ID 作者 问题 语言 测评结果 时间 内存 代码长度 提交时间
72521 sh25_wangsj 最大值和最小值的差 C++ 通过 0 MS 244 KB 859 2025-11-01 16:12:44

Tests(1/1):


#include <iostream> using namespace std; int main() { int a,x,j,max,min,s; cin>>a; int arr[666]; bool out=true; for (int i = 0; i < a; i++) { cin >> x; arr[i]=x; } for (int i = 0; i <a; i++) { j=i-1; out=true; while(j>=0){ if(arr[i]>=arr[j]){ out=false; } j=j-1; } if(out==true){ min=arr[i]; } } for (int i = 0; i <a; i++) { j=i-1; out=true; while(j>=0){ if(arr[i]<=arr[j]){ out=false; } j=j-1; } if(out==true){ max=arr[i]; } } s=max-min; cout<<s; return 0; }


测评信息: