题解 | #最高分与最低分之差#
最高分与最低分之差
https://www.nowcoder.com/practice/e0e4f81dcd55408a8973f8033bbeb1d2
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { int n; cin >> n; vector<int> v; for(int i = 0; i < n; i++) { int tmp; cin >> tmp; v.push_back(tmp); } sort(v.begin(), v.end()); cout << v[v.size()-1] - v[0] << endl; }