Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<cmath>
- using namespace std;
- class Point {
- private:
- char label;
- double x, y;
- public:
- Point();
- void setP(char, double, double);
- void readP();
- double distP();
- char getLabel();
- double getX();
- double getY();
- };
- Point::Point() {
- x = y = 0;
- label = '-';
- }
- void Point::setP(char nc, double nx, double ny) {
- label = nc;
- x = nx;
- y = ny;
- }
- void Point::readP() {
- cout << "label: "; cin >> label;
- cout << "X: "; cin >> x;
- cout << "Y: "; cin >> y;
- }
- double Point::distP() {
- return sqrt(x*x + y*y);
- }
- char Point::getLabel() {
- return label;
- }
- double Point::getX() {
- return x;
- }
- double Point::getY() {
- return y;
- }
- int main() {
- Point A, B;
- char c;
- double x, y;
- cout << "label: ";
- cin >> c;
- cout << "X: ";
- cin >> x;
- cout << "Y: ";
- cin >> y;
- A.setP(c, x, y);
- B.readP();
- if (A.distP() != B.distP()) {
- if (A.distP() < B.distP()) {
- c = A.getLabel();
- x = A.getX();
- y = A.getY();
- } else {
- c = B.getLabel();
- x = B.getX();
- y = B.getY();
- }
- cout << c << " -( " << x << " ; " << y << " ) " << endl;
- } else {
- cout << "Tochkite sa na ravni raztoqniq." << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement