Week 6 computer task project 3-plane coordinate points

Source: Internet
Author: User
01. /* 02. * copyright and version Declaration of the program part 03. * Copyright (c) 2013, Yantai University Computer college student 04. * All rightsreserved. 05. * file name: CPoint. cpp 06. * Author: Zhao guanzhe 07. * Completion Date: April 8, April 5, 2013. * version: v1.0 09. * input Description: 10. * Problem description: 11. */# include <iostream> # include <cmath> using namespace std; class CPoint {private: double x; // abscissa double y; // ordinate public: CPoint (double xx = 0, double yy = 0); double Distance (CPoint p) const; // Distance between two points (one point is the current point, and the other point is the parameter p) double D Istance0 () const; // The distance from the source CPoint into ricaxis (char style) const; // The style is 'x', 'y', and 'O' respectively, indicating that the x axis is used, y axis, origin symmetric void input (); // input coordinate point void output () in the form of x and y; // output coordinate point in the form of (x, y)}; CPoint:: CPoint (double xx, double yy) {x = xx, y = yy;} double CPoint: Distance (CPoint p) const {return sqrt (p. x-x) * (p. x-x) + (p. y-y) * (p. y-y);} double CPoint: Distance0 () const {return sqrt (x * x + y * y);} CPoint: Unsupported ricaxis (char style) con St {double c_x = x, c_y = y; switch (style) {case 'X': c_x =-x; break; case 'y': c_y =-y; break; case 'O': c_x =-x; c_y =-y; break;} CPoint cp (c_x, c_y); // convert c_x, c_y value is initialized to return cp to this object; // returns this object point} void CPoint: input () {char; do {cout <"Enter the coordinates of the vertex (for example, in the form of (x, y):"; cin> x> a> y;} while (! = ',');} Void CPoint: output () {cout <"(" <x <"," <y <") "<endl ;}int main () {CPoint C; C. input (); CPoint cp1 (1.0, 1.0), cp2 (1.0, 0.0); C. output (); cout <"to"; cp1.output (); cout <"distance:" <C. distance (cp1) <endl; C. output (); cout <"to"; cp2.output (); cout <"distance:" <C. distance (cp2) <endl; C. output (); cout <"the distance to the origin is:" <C. distance0 () <endl; C. output (); cout <"the symmetry points on the X axis are:"; C. symmetricAxis ('x '). output (); cout <endl; C. output (); cout <"the symmetry points about the Y axis are:"; C. using ricaxis ('y '). output (); cout <endl; C. output (); cout <"the point of symmetry about the origin is:"; C. using ricaxis ('O '). output (); cout <endl; return 0 ;}

Running result:

Experience:

At last, errors always occur. I asked the teacher, but I wrote the main as mian. It really should be done ....

Related Article

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: info-contact@alibabacloud.com 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.