# 距离产生美

C++代码如下，只需提交空缺部分

#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;
/***********************/

填空部分

/***********************/

double Distance(Point &p1,Point &p2)
{
double d;
d=sqrt((p1.x-p2.x)*1.0*(p1.x-p2.x)+(p1.y-p2.y)*1.0*(p1.y-p2.y));
return d;
}
int main()
{
double d;
Point p1,p2;
p1.input();
p2.input();
d=Distance(p1,p2);
int r1,r2;
cin>>r1>>r2;
if(d>=r1&&d<=r2)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
return 0;
}

``````10 10
20 20
12 15``````

``Yes``

``````#include<stdio.h>
int main()
{
float a,b,c,d,e,f,g,h;
scanf("%f %f",&a,&b);
scanf("%f %f",&c,&d);
scanf("%f %f",&e,&f);
g=(a-c)*(a-c)+(b-d)*(b-d);
e=e*e;
f=f*f;
if(g>=e&&g<=f)
printf("Yes\n");
else
printf("No\n");
}``````

``````
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;
class Point
{
public:
void input();
friend double Distance(Point &p1,Point &p2);
private:
int x;
int y;
};
void Point::input()
{
cin>>x>>y;
}
double Distance(Point &p1,Point &p2)
{
double d;
d=sqrt((p1.x-p2.x)*1.0*(p1.x-p2.x)+(p1.y-p2.y)*1.0*(p1.y-p2.y));
return d;
}
int main()
{
double d;
Point p1,p2;
p1.input();
p2.input();
d=Distance(p1,p2);
int r1,r2;
cin>>r1>>r2;
if(d>=r1&&d<=r2)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;
return 0;
}
``````