Advertisement
myname0

пары

Jul 3rd, 2015
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.13 KB | None | 0 0
  1. #include <algorithm>
  2. #include <utility>
  3. #include <fstream>
  4. #include <vector>
  5. #include <math.h>
  6.  
  7. using namespace std;
  8.  
  9.  
  10. bool diag (pair<int,int> a)
  11. {
  12.     return (a.second == a.first);
  13. }
  14.  
  15. bool eq(pair<int,int> a, pair <int, int> b)
  16. {
  17.     return a.first < b.first;
  18. }
  19.  
  20. }
  21. bool comp (pair<int,int> a)
  22. {
  23.     return (a.first > 0 && a.second < 0);
  24. }
  25. bool comparator(pair <int,int> a, pair <int, int> b)
  26. {
  27.    
  28.     return ( a.first * a.first + a.second * a.second <  b.first * b.first + b.second * b.second ) ;
  29. }
  30.  
  31.  
  32. int main()
  33. {
  34.     ifstream in("input.txt");
  35.     ofstream out("output.txt");
  36.  
  37.     vector <pair<int, int>> vec;
  38.     int n;
  39.     int m;
  40.     while(in.peek() != EOF)
  41.     {
  42.         in >> n>> m;
  43.         vec.push_back(make_pair(n, m));
  44.     }
  45.     vec.erase(remove_if(vec.begin(), vec.end(),comp), vec.end());  
  46.     for(int i = 0; i < (int) vec.size(); i++)
  47.         out << "(" << vec[i].first << ", " << vec[i].second << ")"<< endl;
  48.     out << " count of points on x=y: " << count_if(vec.begin(),vec.end(),diag);
  49.     for_each
  50.     sort(vec.begin(), vec.end(), eq);
  51.     for(int i = 0; i < (int) vec.size(); i++)
  52.         out << "(" << vec[i].first << ", " << vec[i].second << ")"<< endl;
  53.     return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement