本题链接:201712-1 最小差值
本博客给出本题截图:
C++
#include <iostream> #include <algorithm> using namespace std; const int N = 1010; int n; int q[N]; int main() { cin >> n; for (int i = 0; i < n; i ++ ) cin >> q[i]; int res = 1e8; for (int i = 0; i < n; i ++ ) for (int j = i + 1; j < n; j ++ ) res = min(res, abs(q[i] - q[j])); cout << res << endl; return 0; }
总结
水题,不解释