Program egor_sasha; var num_eg, num_sash,pri,pri1: real; var mes_eg,mes_sash: real; beginwriteln('numer egora'); readln(num_eg); writeln('numer sashi'); readln(num_sash); writeln('mesto egora (verkh=1,vniz=0)'); readln(mes_eg); writeln('mesto sashi (verkh=1,vniz=0)'); readln(mes_sash); pri: =num_sash+1; pri1: =num_eg+1; if num_eg=pri then writeln('yes') else writeln('no'); if num_sash=pri1 then writeln('yes') else writeln('no'); if mes_eg=1 then writeln('egor-high')else writeln('egor-low'); if mes_sash=1 then writeln('sasha-high')else writeln('sasha-low'); end.
#include <cmath>
using namespace std;
class Circle
{
private:
double x;
double y;
double r;
public:
Circle();
Circle(double xCo, double yCo, double rad);
double area();
double centre_dist(Circle & c);
bool istouch(Circle & c);
};
Circle::Circle()
{
cout << "Enter x coord: ";
cin >> x;
cout << "Enter y coord: ";
cin >> y;
cout << "Enter radius: ";
while (cin >> r && r < 0)
{
cout << "Radius can't be negative\n";
cout << "Enter radius: ";
}
}
Circle::Circle(double xCo, double yCo, double rad) : x(xCo), y(yCo), r(rad)
{
if (r < 0)
{
cout << "Radius can't be negative\n";
cout << "Radius set to 0\n";
r = 0;
}
}
double Circle::area()
{
return 3.1415926 * r * r;
}
double Circle::centre_dist(Circle & c)
{
return sqrt((x - c.x) * (x - c.x) + (y - c.y) * (y - c.y));
}
bool Circle::istouch(Circle & c)
{
return (this->centre_dist(c) <= r + c.r) ? true : false;
}
int main()
{
Circle c1;
Circle c2(0, 0, 5);
cout << "area of c2: " << c2.area() << endl;
cout << "centre distance: " << c2.centre_dist(c1) << endl;
cout << "is touch: ";
c2.istouch(c1) ? cout << "yes" : cout << "no";
cout << endl;
return 0;
}