Advertisement
SelinD

v90s3ex4

Mar 26th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. #include<iostream>
  2. #include<fstream>
  3. #include<cmath>
  4. using namespace std;
  5. ifstream fin("bac.txt.cpp");
  6. int main()
  7. {
  8. int s=0,smax=0,xant,x,dmax=0,a,b;
  9. fin>>xant;
  10. while(fin>>x)
  11. {
  12. if(xant>0 && x>0)
  13. {
  14. s=xant+x;
  15. if(s>smax || s==smax && abs(x-xant)>dmax)
  16. {
  17. smax=s;
  18. dmax=abs(x-xant);
  19. a=xant;
  20. b=x;
  21. }
  22. }
  23. xant=x;
  24. }
  25. cout<<a<<" "<<b;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement