Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- ifstream f("date.txt");
- int main()
- {
- long x, y, mx=0, my=0;
- f >> x;
- while( f >> y )
- {
- if(x > 0 && y > 0 && x + y > mx + my)
- {
- mx = x;
- my = y;
- }
- else if(x > 0 && y > 0 && x + y == mx + my )
- {
- int d1 = 0, d2 = 0;
- if(x - y > 0)
- d1 = x - y;
- else
- d1 = y - x;
- if(mx - my > 0)
- d2 = mx- my;
- else
- d2 = my - mx;
- if(d1 > d2)//abs( x - y ) > abs( mx - my ))
- {
- mx = x;
- my = y;
- }
- }
- x = y;
- }
- cout << mx << " " << my;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement