#include <iostream>
#ifdef __BORLANDC__
  #include <math>
  #include <limits>
#else
  using namespace std;
  #include <cmath>
#endif

struct Punkt
  {
   double x,y;
   Punkt():x(0),y(0) {}
   Punkt(double x,double y):x(x),y(y) {}
   double Odleglosc(double px,double py)const;
   double operator-(const Punkt &B)const;
   double operator-()const;
  };

double Punkt::Odleglosc(double px,double py)const
  {
   py-=y;
   px-=x;
   return(sqrt(px*px+py*py));
  }

ostream &operator <<(ostream &s,const Punkt &P)
  {
   return(s<<'('<<P.x<<','<<P.y<<')');
  }

istream &operator >>(istream &s,Punkt &P)
  {
   double x,y;
   char Coma;
   s>>x>>Coma>>y;
   if(s.good() && Coma!=',') s.clear(s.rdstate()|ios::badbit);
   else
     {
      P.x=x;
      P.y=y;
     }
   return(s);
  }

double Punkt::operator-(const Punkt &B)const
  {
   return(Odleglosc(B.x,B.y));
  }

double Punkt::operator-()const
  {
   return(Odleglosc(0,0));
  }

int main()
  {
   Punkt A(3,4),B(4,3);

   cout<<"A="<<A<<endl;
   cout<<A<<'-'<<B<<'='<<(A-B)<<endl;
   cout<<A<<"-(0,0)"<<'='<<(-A)<<endl;
   while(true)
     {
      cout<<"Podaj B: ";
      cin>>B;
      if(cin.good()) break;
      cin.clear();
      cin.ignore(INT_MAX,'\n');
      cout<<"Blad wprowadzenia"<<endl<<endl;
     }
   cout<<"B="<<B<<endl;
   cout<<A<<'-'<<B<<'='<<(A-B)<<endl;
   return(0);
  }
