zoukankan      html  css  js  c++  java
  • 包含

    #include<iostream>
    #include<cmath>
    using namespace std;
    class Point
    {
        double x,y;
    public:
        Point(double x = 0,double y = 0)
        {
            this -> x = x;
            this -> y =y;
        }
        double getx()
        {
            return x;
        }
        double gety()
        {
            return y;
        }
    };
    class Line
    {
        Point p1,p2;
    public:
        Line(const Point &a,const Point &b): p1(a),p2(b) {}
        double getDistance()
        {
            double detax,detay;
            detax = p1.getx() - p2.getx();
            detay = p1.gety() - p2.gety();
            return sqrt(detax * detax + detay * detay);
        }
    };
    class Triangle
    {
        Line z1,z2,z3;
    public:
        Triangle(const Line &a,const Line &b,const Line &c):z1(a),z2(b),z3(c) {}
        double Area()
        {
            double p,q;
            p=((z1.getDistance()+z2.getDistance()+z3.getDistance())/2);
            q=sqrt(p*((p-z1.getDistance())*(p-z2.getDistance())*(p-z3.getDistance())));
            return q;
        }
    };
    int main()
    {
        float p1,p2,p3,p4,p5,p6;
        cin>>p1>>p2>>p3>>p4>>p5>>p6;
        Point a(p1,p2),b(p3,p4),c(p5,p6);
        Line d(a,b),e(b,c),f(c,a);
        Triangle z(d,e,f);
        double distance,area;
        distance=d.getDistance()+e.getDistance()+f.getDistance();
        area=z.Area();
        cout<<distance<<' '<<area<<endl;
        return 0;
    }
  • 相关阅读:
    [MetaHook] Find a function signature
    [MetaHook] GameUI hook
    [MetaHook] BaseUI hook
    一些常用软件的网络端口协议分类介绍
    Visual C++中最常用的类与API函数
    Ubuntu常用软件安装
    C++字符串完全指引
    C++资源之不完全导引
    超过 130 个你需要了解的 vim 命令
    Little-endian和Big-endian
  • 原文地址:https://www.cnblogs.com/handsometaoa/p/11008276.html
Copyright © 2011-2022 走看看