Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- struct circle{
- float x,y,r;
- void setCenter(float cx,float cy){
- x = cx;
- y = cy;
- }
- float getCenterX(){
- return x;
- }
- float getCenterY(){
- return y;
- }
- void setRadius(float rad){
- r = rad;
- }
- float getRadius(){
- return r;
- }
- float dist(circle c1){
- float d;
- d = sqrt((c1.x-x)*(c1.x-x)+(c1.y-y)*(c1.y-y))-c1.r-r;
- return d;
- }
- };
- int main()
- {
- circle c1;
- c1.setCenter(4,6);
- c1.setRadius(3);
- cout<<"первый : "<<"x="<<c1.getCenterX()<<", y="<<c1.getCenterY()<<", r="<<c1.getRadius()<<endl;
- circle c2;
- c2.setCenter(9,4);
- c2.setRadius(5);
- cout<<"второй : "<<"x="<<c2.getCenterX()<<", y="<<c2.getCenterY()<<", r="<<c2.getRadius()<<endl;
- cout<<c1.dist(c2)<<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement