Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <algorithm>
- using namespace std;
- int main() {
- long long n , r;
- long long a[100];
- int iMin=1000, firstN = 0, secondN=0;
- long long im = 0 , ipm =0;
- cin >> n;
- for (int i = 0; i < n; i++)
- cin >> a[i];
- long long m = a[0];
- long long am = a[0];
- for(int i = 0; i < n;i++){
- ipm= i ;
- for(int j = i+1; j < n;j++){
- im = j ;
- if(std::abs(a[i]-a[j]) < iMin){
- iMin=std::abs(a[i]-a[j]);
- firstN = a[i];
- secondN = a[j];
- }
- }
- }
- std::cout << firstN << " " << secondN<< " " << im<< " "<< ipm;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement