Class District Designer



  • I don't know if there's a point at the coordinates of x,y inside the circumference, I can't figure out what to write int main.

    class Circle
    {
    private:
        double x, y, r;
    public:
        Circle(double r, double x = 0, double y = 0):r(r),x(x),y(y){}
        Circle(const Circle&) = default;
        ~Circle()             = default;
    
    bool isIn(double xx, double yy)
    {
        return (xx-x)*(xx-x)+(yy-y)*(yy-y) <= r*r;
    }
    

    int main() {
    int r=20;
    int x=10;
    int y=10;
    if (xx+yy<=rr) {
    cout<<"ne nahoditsya"<< endl;
    }
    else if (x
    x+yy>=rr) {
    cout<<"nahoditsya"<< endl;
    }
    }
    }



  • Okay, now that my code is out of here, https://ru.stackoverflow.com/a/1345808/195342 - I'm gonna have to eat it, but I'm gonna swallow it. ♪ ♪

    int main()  
    {
        double r=20;
        double x=10;
        double y=10;
        cout<< (Circle(r).isIn(x,y) ? "" : "ne ") << "nahoditsya\n";
    }
    

    Of course, if the county center is at the beginning of the coordinates. ♪ ♪


Log in to reply
 

Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2