Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<fstream>
- #include<cmath>
- using namespace std;
- ifstream fin("bac.txt.cpp");
- int main()
- {
- int s=0,smax=0,xant,x,dmax=0,a,b;
- fin>>xant;
- while(fin>>x)
- {
- if(xant>0 && x>0)
- {
- s=xant+x;
- if(s>smax || s==smax && abs(x-xant)>dmax)
- {
- smax=s;
- dmax=abs(x-xant);
- a=xant;
- b=x;
- }
- }
- xant=x;
- }
- cout<<a<<" "<<b;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement