Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
106449 顾梦琪 最大值与最小值的差 C++ Accepted 1 MS 276 KB 354 2025-01-16 11:38:33

Tests(10/10):


Code:

#include<bits/stdc++.h> using namespace std; int main() { int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } int x = a[0]; for (int i = 0; i < n; i++) { if (a[i] > x) { x = a[i]; } } int b = a[0]; for (int i = 0; i < n; i++) { if (a[i] < b) { b= a[i]; } } cout<<x-b; return 0; }