Răspuns :
Răspuns:
#include <bits/stdc++.h>
using namespace std;
double x1, x2, y, y2, r1, r2, d, k;
int main()
{
cin>>r1>>x1>>y>>r2>>x2>>y2;
d=sqrt((x2-x1)*(x2-x1)+(y2-y)*(y2-y));
if(r1==r2 && y==y2 && x1==x2)
cout<<"infinit";
else
{
if(d==abs(r1-r2) || d==r1+r2 )
cout<<1;
else if (d<r1+r2 && r1+d>r2 && d+r2>r1)
cout<<2;
else
cout<<0;
}
return 0;
}
Explicație:
Daca vrei in loc de libraria#include <bits/stdc++.h> pori pune librariile:
#include <iostream>
#include <cmath>
Răspuns:
#include <bits/stdc++.h>
using namespace std;
double t,i,j,k,xa,xb,r1,yb,r2,sr,p,a,ya;
int main()
{
cin>>r1>>xa>>ya>>r2>>xb>>yb;
k=sqrt((xa-xb)*(xa-xb)+(ya-yb)*(ya-yb));
sr=r1-r2;
if(sr<0)sr=sr*(-1);
if(xa==xb&&ya==yb&&r1==r2)
cout<<"infinit"<<'\n';
else
if(k>r1+r2||k<sr)
cout<<0<<'\n';
else
if(k==r1+r2||k==sr)
cout<<1<<'\n';
else
if(k<r1+r2)
cout<<2<<'\n';
else
if(k==0)
cout<<0<<'\n';
}
Explicație: