int
main()
{
int
l(0);
char
c;
double
a, b;
Point p, q, pt[60];
while
(std::cin>>a>>c>>b)
{
if
(a == b)
p.copy(pt[l].setPoint(a, b));
if
(a > b)
p.copy(pt[l].setPoint(a, b).inverse());
if
(a < b)
p.inverse(pt[l].setPoint(a, b));
if
(a < 0)
q.copy(p).inverse();
if
(b < 0)
q.inverse(p).copy(pt[l]);
pt[l++].show();
p.show();
}
q.show();
cout<<
"==========gorgeous separator=========="
<<endl;
double
x(0), y(0);
for
(
int
i = 0; i < l; i++)
x += pt[i].x(), y -= pt[i].y();
pt[l].x(y), pt[l].y(x);
q.copy(pt[l]).show();
for
(
int
i = 0; i <= l; i++)
pt[i].show();
cout<<
"==========gorgeous separator=========="
<<endl;
const
Point const_point(3, 3);
const_point.show();
for
(
int
i = 0; i <= l; i++)
{
if
(const_point.isEqual(pt[i]))
{
ShowPoint(const_point);
ShowPoint(const_point.x(), const_point.y());
ShowPoint(Point(const_point.x(), const_point.y()));
}
}
const_point.showSumOfPoint();
}
代码
#include <iostream>
#include <iomanip>
using namespace std;
class Point
{
double m,n;
int count;
static int sum;
public :
friend void ShowPoint(Point);
friend void ShowPoint(double, double);
void show()const
{
cout<<setprecision(16)<<"Point["<<count<<"] : ("<<m<<", "<<n<<")"<<endl;
}
double x(double a)
{
m = a;
return a;
}
double y(double b)
{
n = b;
return b;
}
double x()const
{
return m;
}
double y()const
{
return n;
}
Point &setPoint(double a,double b)
{
m=a;
n=b;
return *this;
}void showSumOfPoint()const
{
cout << "In total : " <<sum << " points." << endl;
}
Point(double a,double b)
{
m = a;
n = b;
sum++;
count =sum;
}
Point():m(0),n(0)
{
sum++;
count =sum;
}
Point (Point p)
{
setPoint(p.getx(),p.gety());
return *this;
}
Point& inverse()
{
double temp=m;
m=n;
n=temp;
return *this;
}
Point& inverse(Point p)
{
m=p.n;
n=p.m;
return *this;
}
double getx()
{
return this->m;
}
double gety()
{
return this->n;
}
bool isEqual(const Point &p)const
{
if(p.m == m && p.n == n)
return true;
return false;
}
};
void ShowPoint(Point p)
{
cout<<std::setprecision(16)<<"Point : ("<< p.x() <<", "<< p.y() <<")"<<endl;
}
void ShowPoint(double a,double b)
{
cout<<std::setprecision(16)<<"Point : ("<<a<<", "<<b<<")"<<endl;
}
int Point::sum = 0;
int main()
{
int l(0);
char c;
double a, b;
Point p, q, pt[60];
while(std::cin>>a>>c>>b)
{
if(a == b)
p.copy(pt[l].setPoint(a, b));
if(a > b)
p.copy(pt[l].setPoint(a, b).inverse());
if(a < b)
p.inverse(pt[l].setPoint(a, b));
if(a < 0)
q.copy(p).inverse();
if(b < 0)
q.inverse(p).copy(pt[l]);
pt[l++].show();
p.show();
}
q.show();
cout<<"==========gorgeous separator=========="<<endl;
double x(0), y(0);
for(int i = 0; i < l; i++)
x += pt[i].x(), y -= pt[i].y();
pt[l].x(y), pt[l].y(x);
q.copy(pt[l]).show();
for(int i = 0; i <= l; i++)
pt[i].show();
cout<<"==========gorgeous separator=========="<<endl;
const Point const_point(3, 3);
const_point.show();
for(int i = 0; i <= l; i++)
{
if(const_point.isEqual(pt[i]))
{
ShowPoint(const_point);
ShowPoint(const_point.x(), const_point.y());
ShowPoint(Point(const_point.x(), const_point.y()));
}
}
const_point.showSumOfPoint();
}