Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //ZAD2
- #include <iostream>
- #include <vector>
- using namespace std;
- class Point{
- float x,y;
- public:
- float getX() const{return x;}
- void setX(float value){x=value;}
- float getY() const{return y;}
- void setY(float value){y=value;}
- };
- vector <Point>inRectangle(vector <Point> &vec, Point p, Point q){
- vector <Point> result;
- for(int i=0; i< vec.size(); i++){
- Point &tmp=vec[i];
- if(p.getX()<=tmp.getX() && q.getX()>=tmp.getX() && p.getY()>=tmp.getY() && q.getY()<=tmp.getY())
- result.push_back(tmp);
- }
- return result;
- }
- int main()
- {
- vector<Point> vec(10);
- for(int i=0; i<vec.size(); i++){
- vec[i].setX(i);
- vec[i].setY(2*i);
- }
- Point p, q;
- p.setX(0);
- p.setY(6);
- q.setX(6);
- q.setY(2);
- vector<Point> vec2;
- vec2=inRectangle(vec, p, q);
- for(int i=0; i<vec2.size(); i++){
- cout << vec2[i].getX() << ", " << vec2[i].getY() << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement