初学者的有关问题，代码有点长(2)

www.MyException.Cn  网友分享于：2013-04-23  浏览：5次

}
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();
}

Point : (1, 2)
Point : (3, 3)
Point : (2, 1)
Point : (1, 1)
Point : (4, -3)
==========gorgeous separator==========
Point : (1, 0)
Point : (3, 3)
Point : (0, 0)
Point : (4, -3)
Point : (1, 0)
Point : (1, 0)
==========gorgeous separator==========
In total : 66 points.

Point : (1, 2)
Point : (3, 3)
Point : (2, 1)
Point : (1, 1)
Point : (4, -3)
==========gorgeous separator==========
Point[1] : (1, 0)
Point[2] : (3, 3)
Point[3] : (0, 0)
Point[4] : (4, -3)
Point[64] : (1, 0)
Point[64] : (1, 0)
==========gorgeous separator==========
In total : 66 points.

------解决方案--------------------

void show(int index)
{
cout<<std::setprecision(16)<<"Point["<<index<<"] : "<<'('<<x1<<c1<<' '<<y1<<')'<<'\n';

}
index就是你的1,2,3,4,64,64
------解决方案--------------------

------解决方案--------------------