Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <fstream>
- #include <cmath>
- #include <algorithm>
- using namespace std;
- struct okrag{
- int x, y, r;
- okrag(int _x, int _y, int _r){
- x = _x;
- y = _y;
- r = _r;
- }
- };
- bool po_x_i_y(okrag o1, okrag o2){
- if(o1.x<o2.x)return true; else if(o1.x==o2.x)
- {if(o1.y<o2.y)return true;} return false;
- }
- int main() {
- ifstream o("okregi.txt");
- int x, y, r;
- vector<okrag> StyczneDoX;
- while(o >> x >> y >> r){
- if(abs(y) == r){
- StyczneDoX.push_back(okrag(x, y, r));
- }
- }
- o.close();
- ofstream wynik("wynik2.txt");
- sort(StyczneDoX.begin(), StyczneDoX.end(), po_x_i_y);
- for(int i = 0; i<StyczneDoX.size(); i++){
- wynik << StyczneDoX[i].x << " " << StyczneDoX[i].y << " " << StyczneDoX[i].r << endl;
- }
- wynik << StyczneDoX.size() << endl;
- wynik.close();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement