Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
116714 | 何松羽 | 最大值与最小值的差 | C++ | Accepted | 1 MS | 272 KB | 356 | 2025-04-12 12:53:17 |
#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 c = a[0]; for (int i = 1; i < n; i++) { if (a[i] > c) { c = a[i]; } } int x = a[0]; for (int i = 1; i < n; i++) { if (a[i] < x) { x = a[i]; } } cout << c - x; return 0; }