Progaram Calculating distance points C++

To determine the location of a point on the plane required the initial benchmark. Initial benchmark is made of two number lines that intersect riel perpendicular at the null point, which is a flat (horizontal) and the other upright (vertical). A horizontal line called the X-axis, and a vertical line called the axis Y. Two mutually perpendicular axes is called a Cartesian coordinate system perpendicular or simply coordinate Kartesius.dalam times inni case will make sustu example program that is associated with point atupun cartesian coordinates of two points, we suppose to calculate the distance from the coordinates of two points A ( x1, y1) and B (x2, y2) and this is the shape of his program by using Overloding in C + +;

    # include
    # include

    class count {
         friend ostream & operator <<(ostream &, & count);
         friend istream & operator>> (istream &, & count);

    public:
         count ();
         hitung_jarak void () {distance = ((Y2-Y1) * (Y2-Y1) - (X2-X1) * (X2-X1));}

    private:
         float X1, X2, Y1, Y2, distance;
         };

    count:: count () {
                court <
        court <<"Progaram Calculating distance points C++" <
        court <
        }

    istream & operator>> (istream & ins, & mlebu count) {
         court <<"Enter the point X1 =";
         in>> mlebu.X1;
         court <<"Enter the point X2 =";
         in>> mlebu.X2;
         court <<"Enter the point Y1 =";
         in>> mlebu.Y1;
         court <<"Enter the point Y2 =";
         in>> mlebu.Y2;
         return in;
         }

    ostream & operator <<(ostream & out, count & metu) {
         court <
         court <<"Show Total distance =" <<
         return out;
         }

    main () {
    count x;
    cin>> x;
    x.hitung_jarak ();
    court <

    getch ();
    return 0;
    }


0 comments:

Twitter Delicious Facebook Digg Favorites More