Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <utility>
- #include <fstream>
- #include <vector>
- #include <math.h>
- using namespace std;
- bool diag (pair<int,int> a)
- {
- return (a.second == a.first);
- }
- bool eq(pair<int,int> a, pair <int, int> b)
- {
- return a.first < b.first;
- }
- }
- bool comp (pair<int,int> a)
- {
- return (a.first > 0 && a.second < 0);
- }
- bool comparator(pair <int,int> a, pair <int, int> b)
- {
- return ( a.first * a.first + a.second * a.second < b.first * b.first + b.second * b.second ) ;
- }
- int main()
- {
- ifstream in("input.txt");
- ofstream out("output.txt");
- vector <pair<int, int>> vec;
- int n;
- int m;
- while(in.peek() != EOF)
- {
- in >> n>> m;
- vec.push_back(make_pair(n, m));
- }
- vec.erase(remove_if(vec.begin(), vec.end(),comp), vec.end());
- for(int i = 0; i < (int) vec.size(); i++)
- out << "(" << vec[i].first << ", " << vec[i].second << ")"<< endl;
- out << " count of points on x=y: " << count_if(vec.begin(),vec.end(),diag);
- for_each
- sort(vec.begin(), vec.end(), eq);
- for(int i = 0; i < (int) vec.size(); i++)
- out << "(" << vec[i].first << ", " << vec[i].second << ")"<< endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement