Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <cmath>
- using namespace std;
- vector <int> numbers;
- int main(){
- int arraySize;
- cin >> arraySize;
- int numbers [arraySize];
- for (int i = 0; i < arraySize; i++){
- cin >> numbers [i];
- }
- int absRecord = INT8_MAX;
- int absMin;
- for (int i = 0; i < arraySize; i++){
- for (int k = 0; k < arraySize; k++){
- if (i != k){
- absMin = abs (numbers [i] - numbers [k]);
- }
- if (absMin < absRecord ){
- absRecord = absMin;
- }
- }
- }
- if (arraySize > 1){
- cout << absRecord << endl;
- } else {
- cout << 0 << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement