?? 兩點(diǎn)間距離得矩形.txt
字號:
#include<iostream>
#include<cmath>
using namespace std;
class Point
{
public:
Point (int xx=0, int yy=0) {X=xx;Y=yy;}
Point (Point &p);
int GetX() {return X;}
int GetY() {return Y;}
private:
int X,Y;
};
Point::Point(Point&p)
{
X=p.X;
Y=p.Y;
}
class Rectangle
{
public:
Rectangle (Point xp1, Point xp2);
Rectangle (Rectangle &L);
double Getx0() {return len1;}
double Getarea() {return fabs(len2*len1);}
private:
Point p1,p2;
double len1,len2;
};
Rectangle::Rectangle(Point xp1, Point xp2)
:p1(xp1),p2(xp2)
{
len1=double(p1.GetX()-p2.GetX());
len2=double(p2.GetY()-p1.GetY());
}
Rectangle::Rectangle( Rectangle &L):p1(L.p1),p2(L.p2)
{
len1=L.len1;
len2=L.len2;
}
int main()
{
Point myp1(4,5),myp2(1,3);
Rectangle R(myp1,myp2);
cout<<"面積="<<R.Getarea()<<endl;
cout<<"x="<<R.Getx0()<<endl;
return 0;
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -