#include
#include
using namespace std;
class point
{
public:
point();
point(int a,int b);
void distance();
void offset(int a);
void offset(int a,int b);
void scale(int a);
void scale(int a,int b);
private:
int x;
int y;
};
point::point()
{
x=0;
y=0;
}
point::point(int a,int b)
{
x=a;
y=b;
}
void point::distance()
{
cout<<"\ndistence:"<
void point::offset(int a)
{
cout<<"\n相同偏移前:";
cout<<"x="<
y+=a;
cout<<"相同偏移后:";
cout<<"x="<
void point::offset(int a,int b)
{
cout<<"\n不同偏移前:";
cout<<"x="<
y+=b;
cout<<"不同偏移后:";
cout<<"x="<
void point::scale(int a)
{
cout<<"\n相同缩放前:";
cout<<"x="<
y*=a;
cout<<"相同缩放后:";
cout<<"x="<
void point::scale(int a,int b)
{
cout<<"\n不同缩放前:";
cout<<"x=,"<
y*=b;
cout<<"不同缩放后:";
cout<<"x=,"<
void main()
{
int x,y,i=0;
cout<<"请输入坐标:";
cin>>x>>y;
point p(x,y);
while(1)
{
i=-1;
while(i>5||i<0)
{
cout<<"\n一、计算点到原点的距离,请按1"<
cin>>i;
if(i>5||i<0) cout<<"\n输入错误请重输:";
}
if(i==0) break;
switch(i)
{
case 1:
p.distance();
break;
case 2:
int x1;
cout<<"请输入相同偏移量x1=";
cin>>x1;
p.offset(x1);
break;
case 3:
int y1;
cout<<"请输入不同偏移量x1,y1:";
cin>>x1>>y1;
p.offset(x1,y1);
break;
case 4:
cout<<"请输入相同缩放量x1=";
cin>>x1;
p.scale(x1);
break;
case 5:
cout<<"请输入不同缩放量x1,y1:";
cin>>x1>>y1;
p.scale(x1,y1);
break;
}
}
}
希望对你有所帮助