Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- int main()
- {
- using namespace std;
- int lenght, n;
- cin >> lenght;
- vector<int> arr;
- for (int i = 0; i < lenght; ++i)
- {
- cin >> n;
- arr.push_back(n);
- }
- int min_diff = 0;
- if (lenght > 1)
- {
- min_diff = abs(arr[0] - arr[1]);
- for (int i = 0; i < lenght; ++i)
- for (int j = i + 1; j < lenght; ++j)
- if (abs(arr[i] - arr[j]) < min_diff)
- min_diff = abs(arr[i] - arr[j]);
- }
- cout << min_diff;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment