Advertisement
Guest User

Untitled

a guest
Dec 6th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.25 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. int n,a,b,x,y,Min=1000000000,i;
  6. cin>>n;
  7. cin>>a;
  8. for(i=1;i<n;i++)
  9. {
  10. cin>>b;
  11. int dif=a-b;
  12. if(dif<0)
  13. dif=-1*dif;
  14. if(Min>dif)
  15. {
  16. x=a;
  17. y=b;
  18. Min=dif;
  19. }
  20. a=b;
  21. }
  22. cout<<x<<" "<<y;
  23. return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement