提交时间:2024-11-09 09:56:21
运行 ID: 56073
#include <iostream> using namespace std; int main() { int m; cin >> m; int num; cin >> num; int maxVal = num; int minVal = num; for (int i = 1; i < m; i++) { cin >> num; if (num > maxVal) maxVal = num; if (num < minVal) minVal = num; } cout << maxVal - minVal << endl; return 0; }