CSP-201712-1-最小差值
完整代码
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
int n, minDelta = 10005;
int main() {
cin >> n;
vector<int>arr(n);
for (int i = 0; i < n; i++)
{
cin >> arr[i];
}
for (int i = 0; i < n; i++) {
for (int j = i + 1; j < n; j++)
{
minDelta = min(minDelta, abs(arr[i] - arr[j]));
}
}
cout << minDelta;
return 0;
}