void
ShowPoint(Point p)
{
cout<<std::setprecision(16)<<
"Point : ("
<<p.x()<<
", "
<<p.y()<<
")"
<<endl;
}
void
ShowPoint(
double
x,
double
y)
{
Point p(x, y);
cout<<std::setprecision(16)<<
"Point : ("
<<p.x()<<
", "
<<p.y()<<
")"
<<endl;
}
void
ShowPoint(Point &p,
double
x,
double
y)
{
cout<<std::setprecision(16)<<
"Point : ("
<<p.x(x)<<
", "
<<p.x(y)<<
")"
<<endl;
}
int
main()
{
int
l(0);
char
c;
double
a, b;
Point pt[60];
while
(std::cin>>a>>c>>b)
{
if
(a == b)
ShowPoint(pt[l].setPoint(a, b));
if
(a > b)
ShowPoint(a, b);
if
(a < b)
ShowPoint(pt[l], a, b);
l++;
}
Point p(a), q(b);
ShowPoint(q);
double
x(0), y(0);
for
(
int
i = 0; i < l; i++)
x += pt[i].getX(), y -= pt[i].getY();
ShowPoint(pt[l].setX(x), pt[l].setY(y));
cout<<
"==========gorgeous separator=========="
<<endl;
for
(
int
i = 0; i <= l; i++)
pt[i].show();
q.setPoint(q.x() - p.x() + a, q.y() - p.y() + b).show();
q.show();
cout<<
"==========gorgeous separator=========="
<<endl;
p.showSumOfPoint();
}
代码
#include <iostream>
#include <iomanip>
using namespace std;
class Point
{
double m,n;
int cou;
static int sum;
public:
double x(double a)
{
m = a;
return a;
}
double y(double b)
{
n = b;
return b;
}
double x()
{
return m;
}
double y()
{
return n;
}
double getX()
{
return m;
}
double getY()
{
return n;
}
double setX(double a)
{
m = a;
return a;
}
double setY(double a)
{
n = a;
return a;
}
Point(double a,double b)
{
m = a;
n = b;
sum++;
cou = sum;
}
Point()
{
m = n = 0;
sum++;
cou = sum;
}
Point(double a)
{
m = n = a;
sum++;
cou = sum;
}
Point &setPoint(double a,double b)
{
m = a;
n = b;
sum++;
return *this;
}
void show()
{
cout<<setprecision(16)<<"Point["<< cou <<"] : ("<<m<<", "<<n<<")"<<endl;
}
void showSumOfPoint()
{
cout << "In total : "<< sum << " points." << endl;
}
};
int Point::sum = 0;
void ShowPoint(Point p)
{
cout<<std::setprecision(16)<<"Point : ("<<p.x()<<", "<<p.y()<<")"<<endl;
}
void ShowPoint(double x, double y)
{
Point p(x, y);
cout<<std::setprecision(16)<<"Point : ("<<p.x()<<", "<<p.y()<<")"<<endl;
}
void ShowPoint(Point &p, double x, double y)
{
cout<<std::setprecision(16)<<"Point : ("<<p.x(x)<<", "<<p.x(y)<<")"<<endl;
}
int main()
{
int l(0);
char c;
double a, b;
Point pt[60];
while(std::cin>>a>>c>>b)
{
if(a == b)
ShowPoint(pt[l].setPoint(a, b));
if(a > b)
ShowPoint(a, b);
if(a < b)
ShowPoint(pt[l], a, b);
l++;
}
Point p(a), q(b);
ShowPoint(q);
double x(0), y(0);
for(int i = 0; i < l; i++)
x += pt[i].getX(), y -= pt[i].getY();
ShowPoint(pt[l].setX(x), pt[l].setY(y));
cout<<"==========gorgeous separator=========="<<endl;
for(int i = 0; i <= l; i++)
pt[i].show();
q.setPoint(q.x() - p.x() + a, q.y() - p.y() + b).show();
q.show();
cout<<"==========gorgeous separator=========="<<endl;
p.showSumOfPoint();
}