Project 1 in week 11

Source: Internet
Author: User
/** Program Copyright and version description Section * copyright (c) 2013, a student from the computer College of Yantai University. * All rightsreserved. * Prepared by: Liu Mingliang * completed on: July 15, May 10, 2013 * version: V1.0 * input Description: * Problem description: * output: */# include <iostream> # include <cmath> using namespace STD; Class Point // defines the coordinate class {public: Point (): x (0), y (0) {}; point (double x0, double y0): X (x0), y (y0) {}; void printpoint (); // information of the output vertex Double X, Y; // data member, indicating the horizontal and vertical coordinates of the vertex}; void point: printpoint () {cout <"Point :(" <x <", "<Y <") \ n "; // output point} class line: Public point // use the coordinate point class to define the line class, the data member of its base class indicates the midpoint of the straight line {public: Line (point pts, point PTE); // constructor, use the two endpoints of the initialized line and the midpoint double length () described by the base class data members; // calculate and return the length of the Line void printline (); // two endpoints of the output line and the line length PRIVATE: Class Point pts, PTE; // two endpoints of the line}; // The line class member function line is defined below :: line (point pt1, point pt2): Point (pt1.x + pt2.x)/2, (pt1.y + pt2.y)/2) {PTS = pt1; PTE = pt2;} double line:: length () {return SQRT (PTS. x-pte.x) * (PTS. x-pte.x + (PTS. y-pte.y) * (PTS. y-pte.y);} void line: printline () {PTS. printpoint (); Pte. printpoint (); cout <"length is:" <length () <Endl;} int main () {point PS (-), PE ); line L (Ps, PE); L. printline (); // output line l Information (Please completeCode ) Cout <"the middle point of line:"; L. printpoint (); // output the information of the point in the line L (please complete the Code) return 0 ;}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.