Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<cmath>
- using namespace std ;
- class Point {
- private:
- float abs;
- float ord;
- char pnt;
- public:
- void initialise(char, float,float);
- void deplace(float dx,float dy);
- void affiche();
- float GetAbs() {return abs;};
- float GetOrd();
- char GetPnt();
- };
- void Point::initialise(char a,float x,float y)
- {
- pnt= a;
- abs= x;
- ord= y;
- }
- void Point::deplace(float dx, float dy)
- {
- abs=abs+dx;
- ord=ord+dy;
- }
- void Point::affiche()
- {
- cout<<"le point "<<pnt<<" a pour coordonnées:("<<abs<<","<<ord<<")"<<endl;
- }
- inline float Point::GetOrd() {
- return ord;
- }
- char Point::GetPnt(){
- return pnt;
- }
- float distant(Point t1, Point t2)
- {
- float d,x1,x2,y1,y2;
- x1=t1.GetAbs();
- x2=t2.GetAbs();
- y1=t1.GetAbs();
- y2=t2.GetAbs();
- d = sqrt(pow((x1-x2),2)+pow((y1-y2),2));
- return d;
- }
- int main ()
- {
- Point p1, p2;
- p1.initialise('p',1,2);
- p2.initialise('r',2,4);
- p1.affiche();
- p2.affiche();
- cout<<"distance entre "<<p1.GetPnt()<<" et "<<p1.GetPnt()<<" est "<<distant(p1,p2)<<endl;
- p1.deplace(3,4);
- p2.deplace(0,5);
- p1.affiche();
- p2.affiche();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement