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");
- int main()
- {
- int n, i, anterior, curent, Smax=0, S=0, Dmax=0,a,b;
- fin>>anterior;
- while(fin>>curent)
- {
- S=curent+anterior;
- if(anterior>0 && curent >0)
- {
- if(S>Smax)
- {
- Smax=S;
- a=anterior;
- b=curent;
- }
- else if(S==Smax)
- {
- if(abs(curent-anterior)>abs(a-b))
- {
- a=anterior;
- b=curent;
- }
- }
- }
- anterior=curent;
- }
- cout<<a<<" "<<b;
- }
Advertisement
Add Comment
Please, Sign In to add comment