Advertisement
Guest User

Untitled

a guest
Sep 16th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <fstream>
  4. #include <cmath>
  5. #include <algorithm>
  6.  
  7. using namespace std;
  8.  
  9. struct okrag{
  10. int x, y, r;
  11. okrag(int _x, int _y, int _r){
  12. x = _x;
  13. y = _y;
  14. r = _r;
  15. }
  16. };
  17.  
  18. bool po_x_i_y(okrag o1, okrag o2){
  19. if(o1.x<o2.x)return true; else if(o1.x==o2.x)
  20. {if(o1.y<o2.y)return true;} return false;
  21.  
  22. }
  23.  
  24. int main() {
  25. ifstream o("okregi.txt");
  26. int x, y, r;
  27. vector<okrag> StyczneDoX;
  28. while(o >> x >> y >> r){
  29. if(abs(y) == r){
  30. StyczneDoX.push_back(okrag(x, y, r));
  31. }
  32.  
  33.  
  34. }
  35.  
  36. o.close();
  37. ofstream wynik("wynik2.txt");
  38.  
  39. sort(StyczneDoX.begin(), StyczneDoX.end(), po_x_i_y);
  40. for(int i = 0; i<StyczneDoX.size(); i++){
  41. wynik << StyczneDoX[i].x << " " << StyczneDoX[i].y << " " << StyczneDoX[i].r << endl;
  42. }
  43.  
  44. wynik << StyczneDoX.size() << endl;
  45.  
  46. wynik.close();
  47.  
  48. return 0;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement