Week 6 computer task Project 5-multiple files in one project

Source: Internet
Author: User
Tags cmath
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> # include "class. h "using namespace std; int main () {CPoint a (0, 0), B (1, 1), c (1, 0); CTriangle sj (a, B, c);. output (), B. output (), c. output (); cout <"triangle:" <endl; cout <"perimeter :" <Sj. perimeter () <endl; cout <"area:" <sj. area () <endl; cout <(sj. isRightTriangle ()? "Yes": "not") <"right triangle. "<Endl; cout <(sj. isIsoscelesTriangle ()? "Yes": "no") <"isosceles triangle. "<Endl; CPoint a2 (0, 0), b2 (0,), c2 (5, 0); CTriangle sj2 (a2, b2, c2); a2.output (), b2.output (), c2.output (); cout <"triangle:" <endl; cout <"perimeter:" <sj2.perimeter () <endl; cout <"Area:" <sj2.area () <endl; cout <(sj2.isRightTriangle ()? "Yes": "not") <"right triangle. "<Endl; cout <(sj2.isIsoscelesTriangle ()? "Yes": "no") <"isosceles triangle. "<Endl; system (" PAUSE "); return 0 ;}
 
 
// Vertex class # include <iostream> # include <cmath> # include "class. h "using namespace std; class CPoint {private: float x; // abscissa float y; // ordinate public: CPoint (float xx = 0, float yy = 0 ); float Distance (CPoint p) const; // Distance between two points (one point is the current point, and the other point is the parameter p) void input (); // use x, input coordinate point void output () in y format; // output coordinate point in (x, y) form}; CPoint: CPoint (float xx, float yy) {x = xx, y = yy;} float CPoint: Distance (CPoint p) const {return sqrt (p. x-x )* (P. x-x) + (p. y-y) * (p. y-y);} void CPoint: input () {char a; 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 ;}
 
 
// Triangle class # include <iostream> # include <cmath> # include "class. H "class ctriangle {public: ctriangle (cpoint & X, cpoint & Y, cpoint & Z): A (x), B (Y), C (z) {}// the three-point constructor void settriangle (cpoint & X, cpoint & Y, cpoint & Z); // float perimeter (void ); // calculate the triangle perimeter float area (void); // calculate and return the Triangle Area bool isrighttriangle (); // determine whether it is a right triangle bool isisoscelestriangle (); // whether the isosceles triangle is private: cpoint A, B, C; // three vertices}; void ctriangle: settriangle (Cpoint & X, cpoint & Y, cpoint & Z) {A = X, B = Y, c = z;} float ctriangle: Perimeter (void) {return (. distance (B) + B. distance (c) + C. distance (a);} float ctriangle: Area (void) {float AB =. distance (B), BC = B. distance (C), AC =. distance (c); float P = (AB + BC + AC)/2; Return (SQRT (p * (p-AB) * (p-BC) * (p-AC);} bool ctriangle: isrighttriangle () {float AB =. distance (B), BC = B. distance (C), AC =. distance (c); Return (AB * AB + bc * BC = ac * AC) | (AB * AB + AC * AC = BC * BC) | (AC * AC + bc * BC = AB * AB ))? True: false;} bool ctriangle: isisoscelestriangle () {float AB =. distance (B), BC = B. distance (C), AC =. distance (c); Return (AB = ac | AB = BC | AC = BC )? True: false ;}

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.