Advertisement
Guest User

Untitled

a guest
Feb 26th, 2020
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.99 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4. struct circle{
  5.     float x,y,r;
  6.         void setCenter(float cx,float cy){
  7.             x = cx;
  8.             y = cy;
  9.         }
  10.         float getCenterX(){
  11.             return x;
  12.         }
  13.         float getCenterY(){
  14.             return y;
  15.         }
  16.         void setRadius(float rad){
  17.             r = rad;
  18.         }
  19.        float getRadius(){
  20.             return r;
  21.         }
  22.        float dist(circle c1){
  23.            float d;
  24.            d = sqrt((c1.x-x)*(c1.x-x)+(c1.y-y)*(c1.y-y))-c1.r-r;
  25.            return d;
  26.        }
  27. };
  28. int main()
  29. {
  30.     circle c1;
  31.         c1.setCenter(4,6);
  32.         c1.setRadius(3);
  33.         cout<<"первый : "<<"x="<<c1.getCenterX()<<", y="<<c1.getCenterY()<<", r="<<c1.getRadius()<<endl;
  34.     circle c2;
  35.         c2.setCenter(9,4);
  36.         c2.setRadius(5);
  37.         cout<<"второй : "<<"x="<<c2.getCenterX()<<", y="<<c2.getCenterY()<<", r="<<c2.getRadius()<<endl;
  38. cout<<c1.dist(c2)<<endl;
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement